[Mapbender-commits] r7187 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Dec 3 10:11:11 EST 2010


Author: christoph
Date: 2010-12-03 07:11:11 -0800 (Fri, 03 Dec 2010)
New Revision: 7187

Modified:
   trunk/mapbender/http/plugins/mb_measure_widget.js
Log:
changed destroy/deactivate logic

in progress: view update

Modified: trunk/mapbender/http/plugins/mb_measure_widget.js
===================================================================
--- trunk/mapbender/http/plugins/mb_measure_widget.js	2010-12-03 15:10:22 UTC (rev 7186)
+++ trunk/mapbender/http/plugins/mb_measure_widget.js	2010-12-03 15:11:11 UTC (rev 7187)
@@ -44,8 +44,6 @@
 		defaultHtml = "<div title='" + title + "'>" +
 			"<div class='mb-measure-text'>Fahren Sie mit der Maus &uuml;ber die Karte, um die Koordinaten anzuzeigen.<br> Klicken Sie, um eine Messung zu starten</div>" +
 		"</div>",
-		totalDistance,
-		currentDistance,
 		informationHtml =
 			"<div>Letzter Punkt: <span class='mb-measure-clicked-point' /></div>" +
 			"<div>Aktuelle Koordinaten: <span class='mb-measure-current-point' /></div>" +
@@ -77,7 +75,8 @@
 			autoOpen: false,
 			position: [o.$target.offset().left, o.$target.offset().top]
 		}).bind("dialogclose", function () {
-			that.deactivate();
+			button.stop();
+			that.destroy();
 		});
 
 		//
@@ -152,31 +151,69 @@
 		measureDialog.find(".mb-measure-area").text(area).parent().show();
 	};
 
+	var updateView = function (evt, data) {
+		if (perimeter === null) {
+			return;
+		}
+
+		if (data.distance) {
+			var lastDistanceUnit = "m";
+			var displayDistance = data.distance;
+			if (displayDistance > 10000){
+				displayDistance /= 1000;
+				lastDistanceUnit = "km";
+			}
+			measureDialog.find(".mb-measure-distance-last-unit").html(lastDistanceUnit);
+			measureDialog.find(".mb-measure-distance-last").text(Math.round(displayDistance*10)/10).parent().show();
+
+		}
+
+		if (data.totalDistance) {
+			var totalDistanceUnit = "m";
+			var displayTotalDistance = typeof totalDistance === "number" ? totalDistance + dist : dist;
+			if (displayTotalDistance > 10000){
+				displayTotalDistance = displayTotalDistance / 1000;
+				totalDistanceUnit = "km";
+			}
+
+			measureDialog.find(".mb-measure-distance-total-unit").html(totalDistanceUnit);
+			measureDialog.find(".mb-measure-distance-total").text(Math.round(displayTotalDistance*10)/10).parent().show();
+
+		}
+	};
+
 	this.activate = function () {
 		if (o.$target.size() > 0) {
 			o.$target
 				.mb_measure()
-				.bind("mb_measurepointadded", updateClickedPoint)
+				.bind("mb_measureupdate", updateView)
+/*				.bind("mb_measurepointadded", updateClickedPoint)
 				.bind("mb_measureonmeasure", updateCurrentPoint)
 				.bind("mb_measureonmeasuredistance", updateDistance)
 				.bind("mb_measureonmeasurearea", updateArea)
+				.bind("mb_measureonmeasureperimeter", updatePerimeter)
+				*/
 				.bind("mouseenter", changeDialogContent);
 		}
-
 		measureDialog.dialog("open");
 	};
 
-	this.deactivate = function () {
+	this.destroy = function () {
 		if (o.$target.size() > 0) {
 			o.$target.mb_measure("destroy");
 		}
-
 		hideMeasureData();
 
 		if (measureDialog.dialog("isOpen")) {
 			measureDialog.dialog("close");
 		}
 	};
+	
+	this.deactivate = function () {
+		if (o.$target.size() > 0) {
+			o.$target.mb_measure("deactivate");
+		}
+	};
 
 	create();
 };



More information about the Mapbender_commits mailing list