source: trunk/examples/mapviewer/feature/feature_selector_query.tcl @ 6209

Last change on this file since 6209 was 6209, checked in by dkearney, 7 years ago

adding mapviewer examples from rappture-bat

File size: 1.5 KB
Line 
1package require Rappture
2package require RapptureGUI
3
4Rappture::resources::load
5
6set commondir [file join [file dirname [info script]] .. common]
7source [file join $commondir geovis_settings.tcl]
8
9set width 400
10set height 300
11wm geometry . ${width}x${height}
12update
13
14set mapviewer [Rappture::MapViewer .g]
15
16pack .g -expand yes -fill both
17
18# Parameters for base layer
19array set xyzParams {
20    url {http://otile[1234].mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg}
21}
22array set osm {
23    label "OSM"
24    cache false
25}
26
27# Parameters for feature layer
28array set ogrParams {
29    url {local://afr_countries.shp}
30}
31array set countries {
32    label   "Countries"
33    opacity 0.7
34}
35set stylesheet {
36  s1 {
37    fill: #0000ff;
38    stroke: #000000;
39    stroke-width: 3;
40    altitude-clamping: terrain-drape;
41  }
42  s2 {
43    fill: #ff0000;
44    stroke: #000000;
45    stroke-width: 3;
46    altitude-clamping: terrain-drape;
47  }
48}
49array set selector1 {
50    id    1
51    style s1
52    query "POP2005 < 5000000"
53}
54array set selector2 {
55    id    2
56    style s2
57    query "POP2005 >= 5000000"
58}
59set numSelectors 2
60for {set i 1} {$i < $numSelectors+1} {incr i} {
61   lappend selectors [array get selector$i]
62}
63
64# Create a map object
65set map [Rappture::Map #auto]
66
67# Configure layers
68$map addLayer image \
69    osm [array get osm] \
70    xyz [array get xyzParams]
71
72$map addLayer feature \
73    countries [array get countries] \
74    ogr [array get ogrParams] \
75    $stylesheet "" $selectors
76
77# Add map to viewer
78$mapviewer add $map
79$mapviewer scale $map
80
Note: See TracBrowser for help on using the repository browser.