[Mapbender-commits] r1453 - branches/mapbender_sld/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jun 12 18:22:40 EDT 2007


Author: uli
Date: 2007-06-12 18:22:40 -0400 (Tue, 12 Jun 2007)
New Revision: 1453

Modified:
   branches/mapbender_sld/http/javascripts/map.js
Log:
some more methods of the mapOjb class

Modified: branches/mapbender_sld/http/javascripts/map.js
===================================================================
--- branches/mapbender_sld/http/javascripts/map.js	2007-06-12 22:22:09 UTC (rev 1452)
+++ branches/mapbender_sld/http/javascripts/map.js	2007-06-12 22:22:40 UTC (rev 1453)
@@ -162,9 +162,71 @@
 	};
 	
 	/**
+	 * get the extent as minx, maxx, miny, maxy
+	 *
+	 * @return extent of the mapObj as  minx,minx,maxx,maxy  
+	 * @type Object
+	 */
+	this.getExtentAsObj = function(){
+		var coordslist = this.getExtent().split(",");
+		var coords = new Object();
+		coords.minx = parseFloat(coordslist[0]);
+		coords.miny = parseFloat(coordslist[1]); 
+		coords.maxx = parseFloat(coordslist[2]);
+		coords.maxy = parseFloat(coordslist[3]);
+		return coords;
+	};
+	
+	/**
+	 * zoom the map with a zoomfactor and optional to x,y coords
+	 * 
+	 * @param {boolean} in_ in = true, out = false
+	 * @param {float} factor the zoomfactor 1 equals 100%
+	 * @param {float} x center to x-position
+	 * @param {float} y center to y-position
+	 */
+	 this.zoom = function(in_, factor, x, y){
+		factor = parseFloat(factor);
+		if (!in_) {
+			factor = 1 / factor;
+		}
+		
+		var extent = this.getExtentAsObj();
+		var distx = extent.maxx - extent.minx;
+		var disty =  extent.maxy - extent.miny;
+		
+		
+		if(x && y){
+			var centerx = parseFloat(x);
+			var centery = parseFloat(y);
+		}
+		else{
+			var centerx = extent.minx + distx/2;
+			var centery = extent.miny + disty/2;
+		}
+		
+		
+		var new_distx = distx / factor;
+		var new_disty = disty / factor;
+		var minx = centerx - new_distx / 2;
+		var miny = centery - new_disty / 2;
+		var maxx = centerx + new_distx / 2;
+		var maxy = centery + new_disty / 2;
+		this.setExtent(minx,miny,maxx,maxy);
+		//Todo:
+		//setMapRequest!
+	 }
+
+	/**
+	 * set the extent of the wms
+	 */
+	 this.setExtent = function(minx,miny,maxx,maxy){
+	 	this.extent = String(minx)+","+String(miny)+","+String(maxx)+","+String(maxy);
+	 }
+	
+	/**
 	 * get the srs of the mapObj
 	 *
-	 * @member mb_mapObj_const
 	 * @return srs as epsg:number  
 	 * @type string
 	 */
@@ -175,7 +237,6 @@
 	/**
 	 * get all mapRequests 
 	 *
-	 * @member mb_mapObj_const
 	 * @return array of mapRequests of this map object  
 	 * @type string[]  
 	 */
@@ -194,6 +255,26 @@
 		return false;
 	};
 	
+	/**
+	 * get all MapRequests 
+	 *
+	 * @return array of all mapRequests of this map-object  
+	 * @type string[]  
+	 */
+	this.getMapRequests = function(clickPoint){
+		var allRequests = [];
+		//loop through all wms to get the FeatureInfoRequests
+		for(var i=0; i<this.wms.length; i++){
+			var currentRequest = this.wms[i].getMapRequest(this);
+			if(currentRequest){ 
+				allRequests.push(currentRequest);
+			}
+		}
+		if(allRequests.length > 0){
+			return allRequests;
+		}
+		return false;
+	};
 	
 	/**
 	 * get all featureInfoRequests 
@@ -238,20 +319,27 @@
    }  
 }
 
+/*
+ * get the conjunction character of an URL
+ * @param {String} onlineresource
+ * @return the character & or ?
+ * @type String
+ */
 function mb_getConjunctionCharacter(onlineresource){
+	var conChar;
 	if(onlineresource.indexOf("?") > -1){ 
 		if(onlineresource.charAt(onlineresource.length-1) == "?"){ 
-			nextvalue = "";
+			conChar = "";
 		}else if(onlineresource.charAt(onlineresource.length-1) == "&"){
-			nextvalue = "";
+			conChar = "";
 		}else{
-			nextvalue = "&";
+			conChar = "&";
 		}
 	}
 	if(onlineresource.indexOf("?") == -1){
-		nextvalue = "?";
+		conChar = "?";
 	} 
-	return nextvalue;  
+	return conChar;  
 }
 
 
@@ -433,6 +521,8 @@
 	for(var i=0; i<mb_mapObj.length; i++){
 		var newMapRequest = "";
 		if(mb_mapObj[i].frameName == frameName){
+			//for the new class-methods:
+			mb_mapObj[i].getMapRequests();
 			for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){
 				if(mb_mapObj[i].wms[ii].gui_wms_visible > 0){
 					var myDivId = "div_" + ii;          
@@ -762,29 +852,22 @@
        document.getElementById(elName).innerHTML = tagSource;
   }
 }
+/*
+ * global function to zoom a mapobject
+ * 
+ * use: mb_mapObj.zoom() {@link mb_mapObj_const#zoom}
+ * @deprecated
+ * 
+ */
 function zoom(frameName,in_, factor,x,y) {
-  var x = parseFloat(x);
-  var y = parseFloat(y);
-  var ind = getMapObjIndexByName(frameName);
-  var arrayBBox = mb_mapObj[ind].extent.split(",");
-  var xtentx = parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]);
-  var xtenty =  parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
-  var centerx = parseFloat(arrayBBox[0]) + xtentx/2;
-  var centery = parseFloat(arrayBBox[1]) + xtenty/2;
-  var factor = parseFloat(factor);
-  if(x){
-   centerx = x;
-   centery = y;
-  }
-  if (!in_) {factor = 1 / factor;}
-  var new_xtentx = xtentx / factor;
-  var new_xtenty = xtenty / factor;
-  var minx = centerx - new_xtentx / 2;
-  var miny = centery - new_xtenty / 2;
-  var maxx = centerx + new_xtentx / 2;
-  var maxy = centery + new_xtenty / 2;
-  mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
-  setMapRequest(frameName);
+	var obj = getMapObjByName(frameName);
+	if(x && y){
+		obj.zoom(in_, factor, x, y);
+	}
+	else{
+		obj.zoom(in_, factor, false, false);
+	}	
+	setMapRequest(frameName);
 }
 function mb_panMap(frameName,dir){
    var ind = getMapObjIndexByName(frameName);



More information about the Mapbender_commits mailing list