[fusion-commits] r2614 - in trunk/widgets: . FeatureInfo

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu Oct 4 22:11:02 PDT 2012


Author: jng
Date: 2012-10-04 22:11:02 -0700 (Thu, 04 Oct 2012)
New Revision: 2614

Modified:
   trunk/widgets/FeatureInfo.js
   trunk/widgets/FeatureInfo/featureinfomain.php
Log:
Feature Info widget tweaks
 - #538: Use MapMessage for relaying digitization messages
 - Like the Redline widget, clear out any active digitizer and map messages on widget deactivation

Modified: trunk/widgets/FeatureInfo/featureinfomain.php
===================================================================
--- trunk/widgets/FeatureInfo/featureinfomain.php	2012-09-26 07:55:44 UTC (rev 2613)
+++ trunk/widgets/FeatureInfo/featureinfomain.php	2012-10-05 05:11:02 UTC (rev 2614)
@@ -57,6 +57,10 @@
     $noLayerInfoLocal = GetLocalizedString('FEATUREINFONOINFO', $locale );
     $noFeatureInLocal = GetLocalizedString('FEATUREINFONOFEATUREIN', $locale );
 
+    $drawPointLocal = GetLocalizedString("REDLINEEDITPOINTHELP", $locale );
+    $drawRectLocal = GetLocalizedString("REDLINEEDITRECTANGLEHELP", $locale );
+    $drawPolyLocal = GetLocalizedString("REDLINEEDITPOLYGONHELP", $locale );
+
     try
     {
         $featureInfo = new FeatureInfo($args);
@@ -95,6 +99,10 @@
         var session = '<?= $args['SESSION'] ?>';
         var mapName = '<?= $args['MAPNAME'] ?>';
 
+        var DRAW_POINT_HELP = '<?= $drawPointLocal ?>';
+        var DRAW_RECT_HELP = '<?= $drawRectLocal ?>';
+        var DRAW_POLY_HELP = '<?= $drawPolyLocal ?>';
+
         var properties = null;
         var results;
 
@@ -119,11 +127,23 @@
             map.clearSelection();
         }
 
+        function SetMessage(msg) {
+            var map = GetFusionMapWidget();
+            map.message.info(msg);
+        }
+
+        function ClearMessage() {
+            var map = GetFusionMapWidget();
+            map.message.clear();
+        }
+
         function OnDigitizePoint() {
+            SetMessage(DRAW_POINT_HELP);
             DigitizePoint(OnPointDigitized);
         }
 
         function OnPointDigitized(point) {
+            ClearMessage();
             var tolerance = GetFusionMapWidget().pixToGeoMeasure(3);
             var min = {x:point.X-tolerance,y:point.Y-tolerance};
             var max = {x:point.X+tolerance,y:point.Y+tolerance};
@@ -132,22 +152,26 @@
             SetSpatialFilter(geom);
         }
         function OnDigitizeRectangle() {
+            SetMessage(DRAW_RECT_HELP);
             DigitizeRectangle(OnRectangleDigitized);
         }
 
         function OnRectangleDigitized(rectangle) {
-          var min = rectangle.Point1;
-          var max = rectangle.Point2;
-          var geom = 'POLYGON(('+ min.X + ' ' +  min.Y + ', ' +  max.X + ' ' +  min.Y + ', ' + max.X + ' ' +  max.Y + ', ' + min.X + ' ' +  max.Y + ', ' + min.X + ' ' +  min.Y + '))';
+            ClearMessage();
+            var min = rectangle.Point1;
+            var max = rectangle.Point2;
+            var geom = 'POLYGON(('+ min.X + ' ' +  min.Y + ', ' +  max.X + ' ' +  min.Y + ', ' + max.X + ' ' +  max.Y + ', ' + min.X + ' ' +  max.Y + ', ' + min.X + ' ' +  min.Y + '))';
 
-          SetSpatialFilter(geom);
+            SetSpatialFilter(geom);
         }
 
         function OnDigitizePolygon() {
+            SetMessage(DRAW_POLY_HELP);
             DigitizePolygon(OnPolyonDigitized);
         }
 
         function OnPolyonDigitized(polygon) {
+            ClearMessage();
             var points = [];
             for (var i = 0; i < polygon.Count; i++) {
                 points.push(polygon.Point(i).X+' '+polygon.Point(i).Y);
@@ -267,10 +291,11 @@
         }
 
         function OnUnload() {
-          var map = GetFusionMapWidget();
-          map.deregisterForEvent(Fusion.Event.MAP_SELECTION_ON, SelectionOn);
-          map.deregisterForEvent(Fusion.Event.MAP_SELECTION_OFF, SelectionOff);
-          map.deregisterForEvent(Fusion.Event.MAP_ACTIVE_LAYER_CHANGED, ActiveLayerChange);
+            ClearDigitization(true);
+            var map = GetFusionMapWidget();
+            map.deregisterForEvent(Fusion.Event.MAP_SELECTION_ON, SelectionOn);
+            map.deregisterForEvent(Fusion.Event.MAP_SELECTION_OFF, SelectionOff);
+            map.deregisterForEvent(Fusion.Event.MAP_ACTIVE_LAYER_CHANGED, ActiveLayerChange);
         }
 
     </script>

Modified: trunk/widgets/FeatureInfo.js
===================================================================
--- trunk/widgets/FeatureInfo.js	2012-09-26 07:55:44 UTC (rev 2613)
+++ trunk/widgets/FeatureInfo.js	2012-10-05 05:11:02 UTC (rev 2614)
@@ -42,6 +42,7 @@
     isExclusive: true,
     uiClass: Jx.Button,
     sFeatures: 'menubar=no,location=no,resizable=no,status=no',
+    oTarget: null,
 
     initializeWidget: function(widgetTag) {
         var json = widgetTag.extension;
@@ -53,7 +54,7 @@
         var url = this.sBaseUrl;
         //add in other parameters to the url here
 
-        var map = this.getMap();
+        this.mapWidget = this.getMap();
         var widgetLayer = this.getMapLayer();
         var taskPaneTarget = Fusion.getWidgetById(this.sTarget);
         var pageElement = $(this.sTarget);
@@ -79,12 +80,22 @@
             {
                 taskPaneTarget.setContent(url);
             }
+            this.oTarget = taskPaneTarget.iframe.contentWindow;
         } else {
             if ( pageElement ) {
                 pageElement.src = url;
+                this.oTarget = pageElement;
             } else {
-                window.open(url, this.sTarget, this.sWinFeatures);
+                this.oTarget = window.open(url, this.sTarget, this.sWinFeatures);
             }
         }
+    },
+
+    deactivate: function() {
+        this.mapWidget.message.clear();
+        //This function exists if MapGuideViewerApi.js was included in
+        if (this.oTarget && this.oTarget.ClearDigitization) {
+            this.oTarget.ClearDigitization(true);
+        }
     }
 });



More information about the fusion-commits mailing list