[Mapbender-commits] r7029 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Oct 5 10:51:18 EDT 2010


Author: topi
Date: 2010-10-05 14:51:18 +0000 (Tue, 05 Oct 2010)
New Revision: 7029

Modified:
   trunk/mapbender/http/javascripts/mod_measure.php
Log:
jquery events

Modified: trunk/mapbender/http/javascripts/mod_measure.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_measure.php	2010-10-05 11:44:03 UTC (rev 7028)
+++ trunk/mapbender/http/javascripts/mod_measure.php	2010-10-05 14:51:18 UTC (rev 7029)
@@ -101,41 +101,36 @@
 }
 function mod_measure_go(){
 	var el = mod_measure_mapObj.getDomElement();
-	el.onmousedown = mod_measure_start;
-	el.onmousemove = mod_measure_run;
-	el.onmouseover = function () {
+	if (el) {
+		$(el).bind("mousedown", mod_measure_start)
+			.bind("mousemove", mod_measure_run);
 		el.style.cursor = 'crosshair';
 	}
-	el.onmouseout = function () {
-		el.style.cursor = 'auto';
-	}
+
 	var measureSub = eventAfterMeasure.trigger({}, "CAT");
 	writeTag("",mod_measure_target+"_measure_sub",measureSub);
 }
 function mod_measure_disable(){
 	var el = mod_measure_mapObj.getDomElement();
-	el.onmousedown = null;
-	el.onmousemove = null;
-	el.onmouseover = null;
-	el.onmouseout = null;
+		$(el).unbind("mousedown", mod_measure_start)
+			.unbind("mousemove", mod_measure_run);
 	writeTag("",mod_measure_target+"_measure_display","");
 	writeTag("",mod_measure_target+"_measure_sub","");
 }
 function mod_measure_timeout(){
 	var el = mod_measure_mapObj.getDomElement();
-	el.onmousedown = null;
-	el.ondblclick = null;
-	el.onmousemove = null;
+		$(el).unbind("mousedown", mod_measure_start)
+			.unbind("mousemove", mod_measure_run);
 }
 function mod_measure_disableTimeout(){
 	var el = mod_measure_mapObj.getDomElement();
-	el.onmousedown = mod_measure_start;
-	el.onmousemove = mod_measure_run;
+		$(el).bind("mousedown", mod_measure_start)
+			.bind("mousemove", mod_measure_run);
 }
 function mod_measure_start(e){
-	mod_measure_mapObj.getMousePos(e);
+	var mousepos = mod_measure_mapObj.getMousePosition(e);
 	
-	var realWorldPos = makeClickPos2RealWorldPos(mod_measure_target,clickX,clickY);
+	var realWorldPos = makeClickPos2RealWorldPos(mod_measure_target,mousepos.x,mousepos.y);
 	if(mod_measure_epsg=="EPSG:4326"){
 		mod_measure_RX[mod_measure_RX.length] = realWorldPos[0];
 		mod_measure_RY[mod_measure_RY.length] = realWorldPos[1];
@@ -224,26 +219,26 @@
 	return str_dashedLine;
 }
 function mod_measure_run(e){
-	mod_measure_mapObj.getMousePos(e);
-	var pos = makeClickPos2RealWorldPos(mod_measure_target,clickX,clickY);
+	var mousepos = mod_measure_mapObj.getMousePosition(e);
+	var pos = makeClickPos2RealWorldPos(mod_measure_target,mousepos.x,mousepos.y);
 	var dist;
 	if(mod_measure_epsg=="EPSG:4326"){
 		//convert coordinates to radian
-		var lon_from=(pos[0]*Math.PI)/180;
-		var lat_from=(pos[1]*Math.PI)/180;
+		var lon_from=(pos.x*Math.PI)/180;
+		var lat_from=(pos.y*Math.PI)/180;
 		var lon_to=(mod_measure_RX[mod_measure_RX.length-1]*Math.PI)/180;
 		var lat_to=(mod_measure_RY[mod_measure_RY.length-1]*Math.PI)/180;
 		dist=6371229*Math.acos(Math.sin(lat_from)*Math.sin(lat_to)+Math.cos(lat_from)*Math.cos(lat_to)*Math.cos(lon_from-lon_to));
 	}
 	else{
-		var dist_x = Math.abs(mod_measure_RX[mod_measure_RX.length-1] - pos[0]);
-		var dist_y = Math.abs(mod_measure_RY[mod_measure_RY.length-1] - pos[1]);
+		var dist_x = Math.abs(mod_measure_RX[mod_measure_RX.length-1] - pos.x);
+		var dist_y = Math.abs(mod_measure_RY[mod_measure_RY.length-1] - pos.y);
 		dist=Math.sqrt(dist_x*dist_x+dist_y*dist_y);
 	}
-	if(isNaN(dist) == false && clickX > 0 && clickX < mod_measure_width && clickY > 0 && clickY < mod_measure_height){
+	if(isNaN(dist) == false && mousepos.x > 0 && mousepos.x < mod_measure_width && mousepos.y > 0 && mousepos.y < mod_measure_height){
 		var str_display = "<span style='font-family:"+mod_measure_font+";font-size:"+mod_measure_fontsize+";color:"+mod_measure_color2+";'>"+(Math.round(dist*100)/100)+" m</span>";
 		writeTag("", mod_measure_target+"_measure_display",str_display);
-		mb_arrangeElement("",mod_measure_target+"_measure_display",clickX +2, clickY - 10);
+		mb_arrangeElement("",mod_measure_target+"_measure_display",mousepos.x +2, mousepos.y - 10);
 	}
 	else{
 		writeTag("",mod_measure_target+"_measure_display","");



More information about the Mapbender_commits mailing list