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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Jan 2 06:07:45 EST 2009


Author: christoph
Date: 2009-01-02 06:07:45 -0500 (Fri, 02 Jan 2009)
New Revision: 3383

Modified:
   trunk/mapbender/http/javascripts/mod_measure.php
   trunk/mapbender/http/javascripts/mod_resize_mapsize.php
   trunk/mapbender/http/javascripts/mod_zoomFull.php
Log:
http://trac.osgeo.org/mapbender/ticket/360

Modified: trunk/mapbender/http/javascripts/mod_measure.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_measure.php	2009-01-02 10:53:53 UTC (rev 3382)
+++ trunk/mapbender/http/javascripts/mod_measure.php	2009-01-02 11:07:45 UTC (rev 3383)
@@ -34,6 +34,7 @@
 
 var mod_measure_elName = "measure";
 var mod_measure_frameName = "";
+var mod_measure_mapObj = null;
 var mod_measure_epsg;
 var mod_measure_width;
 var mod_measure_height;
@@ -56,6 +57,31 @@
 });
 
 function init_mod_measure(ind){
+	mod_measure_mapObj = getMapObjByName(mod_measure_target);
+	//ensure we have the div elements in Mapframe
+	var map_el = mod_measure_mapObj.getDomElement()
+	if(!map_el.ownerDocument.getElementById(mod_measure_target+"_measure_sub")){
+		el = map_el.ownerDocument.createElement("div");
+		el.style.position = "absolute";
+		el.style.top = "0px";
+		el.style.left = "0px";
+		el.style.zIndex = "16";
+		el.style.fontSize = "10px";
+
+		el1 = el.cloneNode(false);
+		el2 = el.cloneNode(false);
+
+		el.id = mod_measure_target+"_measure_sub";
+		el.style.zIndex = "19";
+		el1.id = mod_measure_target+"_measure_display";
+		el1.style.zIndex = "17";
+		el2.id = mod_measure_target+"_measuring";
+		
+		map_el.appendChild(el);
+		map_el.appendChild(el1);
+		map_el.appendChild(el2);
+	}
+	
 	mb_button[ind] = document.getElementById(mod_measure_elName);
 	mb_button[ind].img_over = mod_measure_img_over.src;
 	mb_button[ind].img_on = mod_measure_img_on.src;
@@ -69,50 +95,50 @@
 	mb_button[ind].stop = function () {
 		mod_measure_disable();
 	};
-	var ind = getMapObjIndexByName(mod_measure_target);
-	mod_measure_width = mb_mapObj[ind].width;
-	mod_measure_height = mb_mapObj[ind].height;
-	mod_measure_epsg = mb_mapObj[ind].epsg;
+	mod_measure_width = mod_measure_mapObj.width;
+	mod_measure_height = mod_measure_mapObj.height;
+	mod_measure_epsg = mod_measure_mapObj.epsg;
 	eventAfterMapRequest.register(function () {
 		drawDashedLine();
 	});
 	mb_registerPanSubElement("measuring");
 }
 function mod_measure_go(){
-	var el = window.frames[mod_measure_target].document;
+	var el = mod_measure_mapObj.getDomElement();
 	el.onmousedown = mod_measure_start;
 	el.onmousemove = mod_measure_run;
 	el.onmouseover = function () {
-		el.body.style.cursor = 'crosshair';
+		el.style.cursor = 'crosshair';
 	}
 	el.onmouseout = function () {
-		el.body.style.cursor = 'auto';
+		el.style.cursor = 'auto';
 	}
 	var measureSub = eventAfterMeasure.trigger({}, "CAT");
-	writeTag(mod_measure_target,"measure_sub",measureSub);
+	writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measure_sub",measureSub);
 }
 function mod_measure_disable(){
-	var el = window.frames[mod_measure_target].document; 
+	var el = mod_measure_mapObj.getDomElement();
 	el.onmousedown = null;
 	el.onmousemove = null;
 	el.onmouseover = null;
 	el.onmouseout = null;
-	writeTag(mod_measure_target,"measure_display","");
-	writeTag(mod_measure_target,"measure_sub","");
+	writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measure_display","");
+	writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measure_sub","");
 }
 function mod_measure_timeout(){
-	var el = window.frames[mod_measure_target].document; 
+	var el = mod_measure_mapObj.getDomElement();
 	el.onmousedown = null;
 	el.ondblclick = null;
 	el.onmousemove = null;
 }
 function mod_measure_disableTimeout(){
-	var el = window.frames[mod_measure_target].document;
+	var el = mod_measure_mapObj.getDomElement();
 	el.onmousedown = mod_measure_start;
 	el.onmousemove = mod_measure_run;
 }
 function mod_measure_start(e){
-	mb_getMousePos(e,mod_measure_target);
+	mod_measure_mapObj.getMousePos(e);
+	
 	var realWorldPos = makeClickPos2RealWorldPos(mod_measure_target,clickX,clickY);
 	if(mod_measure_epsg=="EPSG:4326"){
 		mod_measure_RX[mod_measure_RX.length] = realWorldPos[0];
@@ -150,12 +176,11 @@
 }
 function drawDashedLine(){
 	//check if epsg has changed
-	var ind = getMapObjIndexByName(mod_measure_target);
-	mod_measure_width = mb_mapObj[ind].width;
-	mod_measure_height = mb_mapObj[ind].height;
-	if(mod_measure_epsg != mb_mapObj[ind].epsg){
+	mod_measure_width = mod_measure_mapObj.width;
+	mod_measure_height = mod_measure_mapObj.height;
+	if(mod_measure_epsg != mod_measure_mapObj.epsg){
 		mod_measure_delete();
-		mod_measure_epsg = mb_mapObj[ind].epsg;
+		mod_measure_epsg = mod_measure_mapObj.epsg;
 	}
 	var str_mPoints = "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='"+mod_measure_width+"' height='0'></div>";
 	str_mPoints += "<div style='position:absolute;left:0px;top:0px' ><img src='"+mb_trans.src+"' width='0' height='"+mod_measure_height+"'></div>";
@@ -178,7 +203,7 @@
 			str_mPoints += evaluateDashes(pos1[0],pos1[1],pos0[0],pos0[1],k);
 		}
 	}
-	writeTag(mod_measure_target,"measuring",str_mPoints);
+	writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measuring",str_mPoints);
 }
 function evaluateDashes(x1,y1,x2,y2,count){
 	var str_dashedLine = "";
@@ -203,7 +228,7 @@
 	return str_dashedLine;
 }
 function mod_measure_run(e){
-	mb_getMousePos(e,mod_measure_target);
+	mod_measure_mapObj.getMousePos(e);
 	var pos = makeClickPos2RealWorldPos(mod_measure_target,clickX,clickY);
 	var dist;
 	if(mod_measure_epsg=="EPSG:4326"){
@@ -221,11 +246,11 @@
 	}
 	if(isNaN(dist) == false && clickX > 0 && clickX < mod_measure_width && clickY > 0 && clickY < 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);
+		writeTag(mod_measure_mapObj.frameName, mod_measure_target+"_measure_display",str_display);
+		mb_arrangeElement(mod_measure_mapObj.frameName,mod_measure_target+"_measure_display",clickX +2, clickY - 10);
 	}
 	else{
-		writeTag(mod_measure_target,"measure_display","");
+		writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measure_display","");
 	}
 }
 function mod_measure_close(){
@@ -263,8 +288,8 @@
 	mod_measure_RY = new Array();
 	mod_measure_Dist = new Array();
 	mod_measure_TotalDist = new Array();
-	writeTag(mod_measure_target,"measuring","");
-	writeTag(mod_measure_target,"measure_display","");
+	writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measuring","");
+	writeTag(mod_measure_mapObj.frameName,mod_measure_target+"_measure_display","");
 }
 
 var mod_closePolygon_img = new Image();
@@ -348,4 +373,4 @@
 		}
 		mod_measure_win.focus();      
 	}
-}
\ No newline at end of file
+}

Modified: trunk/mapbender/http/javascripts/mod_resize_mapsize.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_resize_mapsize.php	2009-01-02 10:53:53 UTC (rev 3382)
+++ trunk/mapbender/http/javascripts/mod_resize_mapsize.php	2009-01-02 11:07:45 UTC (rev 3383)
@@ -93,13 +93,9 @@
 	var coords = mb_mapObj[ind].extent.split(",");
 	midcoordx=parseFloat((parseFloat(coords[2])-parseFloat(coords[0]))/2)+parseFloat(coords[0]);
 	midcoordy=parseFloat((parseFloat(coords[3])-parseFloat(coords[1]))/2)+parseFloat(coords[1]);
-	mb_mapObj[ind].width = mapwidth;
-	mb_mapObj[ind].height = mapheight;
-	document.getElementById(map_frame).style.width = mb_mapObj[ind].width;
-	document.getElementById(map_frame).style.height = mb_mapObj[ind].height;
-	window.frames[map_frame].document.getElementById("maps").style.width = mb_mapObj[ind].width;
-	window.frames[map_frame].document.getElementById("maps").style.height = mb_mapObj[ind].height;
-	mb_repaintScale("<?php  echo $e_target;  ?>",midcoordx,midcoordy,mb_getScale("<?php  echo $e_target;  ?>"));
+	mb_mapObj[ind].setWidth(mapwidth);
+	mb_mapObj[ind].setHeight(mapheight);
+	mb_mapObj[ind].repaintScale(midcoordx,midcoordy,mb_mapObj[ind].getScale());
 }
 
 function rebuild() {

Modified: trunk/mapbender/http/javascripts/mod_zoomFull.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_zoomFull.php	2009-01-02 10:53:53 UTC (rev 3382)
+++ trunk/mapbender/http/javascripts/mod_zoomFull.php	2009-01-02 11:07:45 UTC (rev 3383)
@@ -10,24 +10,9 @@
 
 function mod_zoomFull(){
 	var frameName = "<?php  echo $e_target[0];  ?>"
-	var ind = this.getMapObjIndexByName(frameName);		
-	var width = mb_mapObj[ind].width;
-	var height = mb_mapObj[ind].height;
-
-	// find bounding box of 
-	// first WMS in correct crs
-	// and repaint
-	for (var i = 0; i < wms[0].gui_epsg.length; i++) {
-		if (wms[0].gui_epsg[i] == wms[0].gui_wms_epsg) {
-		
-			var min = new Point(parseFloat(wms[0].gui_minx[i]), parseFloat(wms[0].gui_miny[i]));
-			var max = new Point(parseFloat(wms[0].gui_maxx[i]), parseFloat(wms[0].gui_maxy[i]));     
-		
-			mb_mapObj[ind].repaint(min, max)
-			return true;
-		}
-	}
-	return false;
+    var ind = this.getMapObjIndexByName(frameName);
+	
+	mb_mapObj[ind].zoomFull();
 }
 
 function mod_zoomFull_init(obj){



More information about the Mapbender_commits mailing list