- Timestamp:
- Jun 2, 2016 8:19:06 AM (8 years ago)
- Location:
- branches/multichoice
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/multichoice
- Property svn:mergeinfo changed
-
branches/multichoice/examples/mapviewer/select/select_feature_example.tcl
r6209 r6371 1 package require Tk 1 2 package require Rappture 2 3 package require RapptureGUI … … 7 8 source [file join $commondir geovis_settings.tcl] 8 9 9 # this method is called when a user clicks on a icon in the map 10 # the method is used at the bottom of this example 11 # the callback is called with two arguments: 12 # option - should be one of "annotation", "clear", "feature" 13 proc handler {option {args ""}} { 10 # This method is called when a user modifies the selection in the map view. 11 # This callback is installed in the viewer using setSelectCallback in the code below. 12 # The callback has two arguments: 13 # option - should be one of "annotation", "clear", "feature", "region" 14 # args - depends on option, see below 15 proc selectHandler {option {args ""}} { 14 16 switch $option { 15 17 "annotation" { 16 # pass 18 # An annotation (not in a feature layer) was selected, the single argument 19 # is a list of the selected annotation names. 17 20 } 18 21 "clear" { 19 # previously selected features have been unselected. 20 # no arguments associated with this option. 22 # Previously selected features or annotations have been deselected. 23 # No arguments. 24 puts "select clear" 21 25 } 22 26 "feature" { 23 # a feature was selected, the server returns 4 values about the feature 24 # that are held in args: 25 # globalObjId - the global object identifier 26 # featureIdList - a single value or list of feature identifiers. 27 # if multiple features are returned, they arei 28 # enclosed in curly brackets. 29 # numFeaturesInLayer - the number of features in the layer 30 # layerName - the name of the layer the features were found in. 31 # only features from a single layer can be selected 32 # at a time. 33 foreach {globalObjId featureIdList numFeaturesInLayer layerName} $args break 34 puts "handler caught\ 35 globalObjId=\"$globalObjId\"\ 36 featureIdList=\"$featureIdList\"\ 37 numFeaturesInLayer=\"$numFeaturesInLayer\"\ 38 layerName=\"$layerName\"" 27 # The feature selection set changed, the arguments are: 28 # op - "add", "delete" or "set" 29 # featureIdList - a list of feature identifiers. 30 # layerName - the name of the layer the features were found in. 31 foreach {op featureIdList layerName} $args break 32 switch $op { 33 "add" { 34 puts "select feature add:\nfeatureIDList=\"$featureIdList\"\nlayerName=\"$layerName\"" 35 } 36 "delete" { 37 puts "select feature delete:\nfeatureIDList=\"$featureIdList\"\nlayerName=\"$layerName\"" 38 } 39 "set" { 40 puts "select feature set:\nfeatureIDList=\"$featureIdList\"\nlayerName=\"$layerName\"" 41 } 42 default { 43 error "bad op \"$op\": should be one of: add, delete or set" 44 } 45 } 46 } 47 "region" { 48 # An area defined by two wgs84 corner points was selected. 49 # Here x is wgs84 decimal degrees longitude and y is wgs84 decimal degrees latitude. 50 foreach {xmin ymin xmax ymax} $args break 51 puts "select region: ($xmin, $ymin) - ($xmax, $ymax)" 39 52 } 40 53 default { 41 error "bad option \"$option\": should be one of annotation,\ 42 clean, or feature" 54 error "bad option \"$option\": should be one of: annotation, clear, feature or region" 43 55 } 44 56 } … … 87 99 " 88 100 89 # create a map object101 # Create a map object 90 102 set map [Rappture::Map #auto] 91 103 92 # add all layers to the map object104 # Add all layers to the map object 93 105 $map addLayer image \ 94 106 osm [array get osmParams] \ … … 102 114 $stylesheet 103 115 104 # add a map to the vis client116 # Add a map to the vis client 105 117 $mapviewer scale $map 106 118 $mapviewer add $map 107 119 108 120 109 # set the proc/method to be called when a feature is selected on the map.110 # in this case we give the full path to the previously defined111 # procedure named " handler". for an itcl class method, you may need to112 # use itcl::code to get the full path of the callback method:113 # for example: [itcl::code $this handler]114 $mapviewer setSelectCallback :: handler121 # Set the proc/method to be called when a feature is selected on the map. 122 # In this case we give the full path to the previously defined 123 # procedure named "selectHandler". For an itcl class method, you may need to 124 # use itcl::code to get the full path of the callback method, e.g. 125 # [itcl::code $this selectHandler] 126 $mapviewer setSelectCallback ::selectHandler
Note: See TracChangeset
for help on using the changeset viewer.