[fusion-commits] r3012 - in sandbox/adsk/3.1n/widgets: . Measure

svn_fusion at osgeo.org svn_fusion at osgeo.org
Wed Nov 22 15:59:06 PST 2017


Author: zhanga
Date: 2017-11-22 15:59:06 -0800 (Wed, 22 Nov 2017)
New Revision: 3012

Modified:
   sandbox/adsk/3.1n/widgets/Measure.js
   sandbox/adsk/3.1n/widgets/Measure/Measure.php
Log:
Fix 2 measure issues.
1. fusion error if zoom after click 'Measure' button. It is because the line string is not valid yet. Now add a check for the vertex count before update marker.
2. If there are 2 'Measure' defined (one for distance, the other for area), when switch between the 2 buttons, the 'Unload' of previous page is always after the new page's 'activate', which results in values of some global variables e.g. isDigitizing are not correct. Now we change the event to 'onbeforeunload' to solve the issue.

Modified: sandbox/adsk/3.1n/widgets/Measure/Measure.php
===================================================================
--- sandbox/adsk/3.1n/widgets/Measure/Measure.php	2017-11-13 01:30:39 UTC (rev 3011)
+++ sandbox/adsk/3.1n/widgets/Measure/Measure.php	2017-11-22 23:59:06 UTC (rev 3012)
@@ -83,11 +83,13 @@
         }
         
         function OnUnload() {
-            _widget.deactivate();
+            if (_widget)
+                _widget.deactivate();
         }
         
         function SetWidget(widget) {
             _widget = widget;
+            _widget.getMap().isDigitizing = true;
             _widget.setButtons(document.getElementById("measureStopBtn"), document.getElementById("measureStartBtn"));
         }
         
@@ -101,7 +103,7 @@
     
     </script>
 </head>
-<body id="MeasurementWidgetResults" onload="OnLoad()" onunload="OnUnload()">
+<body id="MeasurementWidgetResults" onload="OnLoad()" onbeforeunload="OnUnload()">
     <h1><?php echo $title ?></h1>
     <hr />
     <p><?php echo $hint ?></p>

Modified: sandbox/adsk/3.1n/widgets/Measure.js
===================================================================
--- sandbox/adsk/3.1n/widgets/Measure.js	2017-11-13 01:30:39 UTC (rev 3011)
+++ sandbox/adsk/3.1n/widgets/Measure.js	2017-11-22 23:59:06 UTC (rev 3012)
@@ -357,6 +357,8 @@
         var at = null;
         var pixQuantity = 0;
         if (geom.CLASS_NAME.indexOf('LineString') != -1) {
+            if(v.length < 2)
+                return;
             from = this.getMap().geoToPix(v[0].x,v[0].y);
             to = this.getMap().geoToPix(v[1].x,v[1].y);
             at = {x: (from.x + to.x) / 2, y: (from.y + to.y) / 2};



More information about the fusion-commits mailing list