source: trunk/examples/mapviewer/ogr/ogr_csv_icon_example.tcl @ 6532

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

Fix map viewer examples to use openstreetmap.org tile servers since mapquest
shut down open tile access.

File size: 1.4 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
19array set xyzParams {
20    url {http://[abc].tile.openstreetmap.org/{z}/{x}/{y}.png}
21}
22array set osm {
23    label "OSM Map"
24    description "MapQuest OpenStreetMap Street base layer"
25    opacity 1.0
26}
27
28# create a feature icon 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://coord.csv"
36set path "local://station_clean.csv"
37array set ogrParams [subst {
38    url {$path}
39}]
40array set iconParams {
41    label  "CSV data"
42    description "using OGR data provider to load data from a CSV file"
43    style "-icon pin3"
44}
45
46# create a map object
47set map [Rappture::Map #auto]
48
49# add all layers to the map object
50$map addLayer image \
51    osm [array get osm] \
52    xyz [array get xyzParams]
53$map addLayer icon \
54    iconParams [array get iconParams] \
55    ogr [array get ogrParams]
56
57# add a map to the vis client
58$mapviewer scale $map
59$mapviewer add $map
Note: See TracBrowser for help on using the repository browser.