source: trunk/examples/mapviewer/placard/placard_disable_example.tcl @ 6299

Last change on this file since 6299 was 6299, checked in by ldelgass, 8 years ago

make examplues use MapViewer::refresh

File size: 1.9 KB
Line 
1package require Tk
2package require Rappture
3package require RapptureGUI
4
5Rappture::resources::load
6
7set commondir [file join [file dirname [info script]] .. common]
8source [file join $commondir geovis_settings.tcl]
9
10set width 400
11set height 300
12wm geometry . ${width}x${height}
13update
14
15set mapviewer [Rappture::MapViewer .g]
16
17pack .g -expand yes -fill both
18
19# create an XYZ world layer
20array set xyzParams {
21    url {http://otile[1234].mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpg}
22}
23array set osm {
24    label "OSM Map"
25    description "MapQuest OpenStreetMap Street base layer"
26}
27
28# create an feature point layer from a csv file using the OGR driver
29# the longitude and latitude fields must be named "longitude" and
30# "latitude" respectively
31#
32# we add the local:// prefix to tell the map viewer widget that
33# the file exists locally and needs to be transferred to the
34# geovis server.
35# set path "local://[file join [file dirname [info script]] coord.csv]"
36set path "local://station_clean.csv"
37array set ogrParams [subst {
38    url {$path}
39}]
40array set stations {
41    label "CSV data"
42    description "using OGR data provider to load data from a CSV file"
43}
44array set placardAttributes {
45    latitude Lat
46    longitude Lon
47}
48set placardStyle {
49    fill: #B6B6B688;
50    text-fill: #000000;
51    text-size: 12.0;
52}
53set placardPadding 5
54
55# create a map object
56set map [Rappture::Map #auto]
57
58# add all layers to the map object
59$map addLayer image \
60    osm [array get osm] \
61    xyz [array get xyzParams]
62$map addLayer icon \
63    stations [array get stations] \
64    ogr [array get ogrParams]
65$map setPlacardConfig stations \
66    [array get placardAttributes] \
67    $placardStyle \
68    $placardPadding
69
70# add a map to the vis client
71$mapviewer scale $map
72$mapviewer add $map
73
74# Make sure the MapViewer rebuilds the map
75$mapviewer refresh
76
77# disable the placard for the "stations" layer of $map
78$mapviewer placard enable off "$map-stations"
Note: See TracBrowser for help on using the repository browser.