source: trunk/examples/mapviewer/layers/repeated_layer_names.tcl @ 6370

Last change on this file since 6370 was 6370, checked in by dkearney, 6 years ago

adding feature multiple selection examples, not all ideas work right now.
using the afr_elas shapefile because they include country elasticity values from the landuse tool.
adding an example of using large stylesheets with multiple colors.
adding example of performing multiple selection by:

  1. deleting and adding a layer by the same name
  2. using a callback
  3. updating a layer with map object's addSelector method and mapviewer's refresh method.
File size: 2.0 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 xyz 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# create an feature icon 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://coord.csv"
35set path "local://coord1.csv"
36array set ogrParams1 [subst {
37    url {$path}
38}]
39array set iconParams1 {
40    label  "CSV data 1"
41    description "using OGR data provider to load data from a CSV file"
42    style "-icon pin3"
43}
44
45set path "local://coord2.csv"
46array set ogrParams2 [subst {
47    url {$path}
48}]
49array set iconParams2 {
50    label  "CSV data 2"
51    description "using OGR data provider to load data from a CSV file"
52    style "-icon pin7"
53}
54
55# create a map object
56set map [Rappture::Map #auto]
57
58# add a layer to the map object
59$map addLayer image \
60    osm [array get osm] \
61    xyz [array get xyzParams]
62
63# add csv layer 1 to the map object
64$map addLayer icon \
65    csvdata [array get iconParams1] \
66    ogr [array get ogrParams1]
67
68$mapviewer scale $map
69$mapviewer add $map
70
71
72after 5000 {
73    # remove csv layer 1 from the map object
74    $map deleteLayer csvdata
75
76    # add csv layer 2 to the map object
77    # with the same layer name as our previous layer
78    $map addLayer icon \
79        csvdata [array get iconParams2] \
80        ogr [array get ogrParams2]
81
82    # Update map viewer
83    $mapviewer clear
84    $mapviewer add $map
85    puts stderr "Deleted csv layer 1, Added csv layer 2"
86}
Note: See TracBrowser for help on using the repository browser.