source: trunk/examples/mapviewer/placard/placard_example.tcl @ 6209

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

adding mapviewer examples from rappture-bat

File size: 1.7 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# create an XYZ world 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 Map"
24    description "MapQuest OpenStreetMap Street base layer"
25}
26
27# create an feature point layer from a csv file using the OGR driver
28# the longitude and latitude fields must be named "longitude" and
29# "latitude" respectively
30#
31# we add the local:// prefix to tell the map viewer widget that
32# the file exists locally and needs to be transferred to the
33# geovis server.
34# set path "local://[file join [file dirname [info script]] coord.csv]"
35set path "local://station_clean.csv"
36array set ogrParams [subst {
37    url {$path}
38}]
39array set stations {
40    label "CSV data"
41    description "using OGR data provider to load data from a CSV file"
42}
43array set placardAttributes {
44    latitude Lat
45    longitude Lon
46}
47set placardStyle {
48    fill: #B6B6B688;
49    text-fill: #000000;
50    text-size: 12.0;
51}
52set placardPadding 5
53
54# create a map object
55set map [Rappture::Map #auto]
56
57# add all layers to the map object
58$map addLayer image \
59    osm [array get osm] \
60    xyz [array get xyzParams]
61$map addLayer icon \
62    stations [array get stations] \
63    ogr [array get ogrParams]
64$map setPlacardConfig stations \
65    [array get placardAttributes] \
66    $placardStyle \
67    $placardPadding
68
69# add a map to the vis client
70$mapviewer scale $map
71$mapviewer add $map
Note: See TracBrowser for help on using the repository browser.