source: branches/geomap/examples/mapviewer/layers/add_remove_layers.tcl @ 5954

Last change on this file since 5954 was 5954, checked in by dkearney, 8 years ago

adding more map layer examples, placing icons on a map and shoing how to add and remove layers from a map.

File size: 2.9 KB
Line 
1package require RapptureGUI
2
3set commondir [file join [file dirname [info script]] .. common]
4source [file join $commondir geovis_settings.tcl]
5
6
7set width 400
8set height 300
9wm geometry . ${width}x${height}
10update
11
12Rappture::MapViewer::SetServerList $GEOVIS_SERVERS
13set s [Rappture::MapViewer .g [list localhost:2015]]
14
15pack .g -expand yes -fill both
16
17# create xyz layer
18set xyzdp [Rappture::GeoMapDataProviderXYZ #auto \
19    {http://otile[1234].mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg} \
20    -cache false]
21set l1 [Rappture::GeoMapLayerImage #auto $xyzdp]
22
23
24# create a colorramp layer
25set colormap {
26 0.00 0 0 1 1
27 0.25 0 1 1 1
28 0.50 0 1 0 1
29 0.75 1 1 0 1
30 1.00 1 0 0 1
31}
32set crdp [Rappture::GeoMapDataProviderColorramp #auto \
33    {file:///usr/share/geovis/landuse/outlandish.tif} \
34    -colormap $colormap]
35set l2 [Rappture::GeoMapLayerImage #auto $crdp]
36$l2 configure -coverage true
37
38
39# create an OGR Line layer
40set ogrdp [Rappture::GeoMapDataProviderOGR #auto \
41    line {file:///data/mygeohub/tools/landuse/afr_countries.shp}]
42set l3 [Rappture::GeoMapLayer #auto $ogrdp]
43
44
45# create a map object
46set m [Rappture::Map #auto]
47
48# -------------------------------------------------
49# launch the mapviewer
50# show individual layers of the map at 10 second intervals
51
52after 10000 {
53    # add a layer to the map object
54    set l1name [ \
55        $m layer add -format blt_tree [ \
56            $l1 export -format blt_tree]]
57
58    # add a map to the vis client
59    $s scale $m
60    $s add $m
61}
62
63after 15000 {
64    # remove the map from the viewer
65    $s remove $m
66
67    # remove the OSM layer from the map
68    $m layer delete $l1name
69
70    # add the colorramp layer to the map
71    set l2name [ \
72        $m layer add -format blt_tree [ \
73            $l2 export -format blt_tree]]
74
75    # add the map back to the viewer
76    $s scale $m
77    $s add $m
78}
79
80after 20000 {
81    # remove the map from the viewer
82    $s remove $m
83
84    # remove the colorramp layer from the map
85    $m layer delete $l2name
86
87    # add the line feature layer to the map
88    set l3name [ \
89        $m layer add -format blt_tree [ \
90            $l3 export -format blt_tree]]
91
92    # add the map back to the viewer
93    $s scale $m
94    $s add $m
95}
96
97# build up the map layer by layer at 5 second intervals
98
99after 25000 {
100    # remove the map from the viewer
101    $s remove $m
102
103    # remove the line feature layer
104    $m layer delete $l3name
105
106    # add the OSM layers to the map
107    $m layer add -format blt_tree [$l1 export -format blt_tree]
108
109    # add the map back to the viewer
110    $s scale $m
111    $s add $m
112}
113
114
115after 30000 {
116    # add the colorramp layer to the map
117    $m layer add -format blt_tree [$l2 export -format blt_tree]
118
119    # add the map back to the viewer
120    $s scale $m
121    $s add $m
122}
123
124after 35000 {
125    # add the line feature layer to the map
126    $m layer add -format blt_tree [$l3 export -format blt_tree]
127
128    # add the map back to the viewer
129    $s scale $m
130    $s add $m
131}
132
Note: See TracBrowser for help on using the repository browser.