[Mapbender-commits] r4837 - branches/2.6/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Oct 20 08:25:30 EDT 2009


Author: christoph
Date: 2009-10-20 08:25:30 -0400 (Tue, 20 Oct 2009)
New Revision: 4837

Modified:
   branches/2.6/http/javascripts/map_obj.js
Log:
merged w/ trunk

Modified: branches/2.6/http/javascripts/map_obj.js
===================================================================
--- branches/2.6/http/javascripts/map_obj.js	2009-10-20 12:24:15 UTC (rev 4836)
+++ branches/2.6/http/javascripts/map_obj.js	2009-10-20 12:25:30 UTC (rev 4837)
@@ -7,6 +7,22 @@
 
 function mb_mapObj_const(frameName, elementName, width, height, wms_index){
 
+	var mapMsgObj;
+
+	eventLocalize.register(function () {
+		localizeMap();
+	});
+
+	eventInit.register(function () {
+		localizeMap();
+	});
+
+	var localizeMap = function () {
+		$.post("../php/mod_map_messages.php", function(obj, status){
+			mapMsgObj = eval('(' + obj + ')');
+		});		
+	};
+
 	/**
 	 * set the extent of the wms
 	 */
@@ -57,7 +73,7 @@
 			return window.frames[this.frameName].document.getElementById(this.elementName);
 		}
 		return document.getElementById(this.elementName);
-	}
+	};
 	
 	/**
 	 * set the height of the mapObj
@@ -143,12 +159,15 @@
 	};
 	
 	var ignoreWms = function (wms) {
-		ignoredWms.push(wms.wms_id);
+		ignoredWms.push({
+			id: wms.wms_id,
+			title: wms.wms_title
+		});
 	};
 	
 	var isIgnoredWms = function (wms) {
 		for (var j = 0; j < ignoredWms.length; j++) {
-			if (ignoredWms[j] === wms.wms_id) {
+			if (ignoredWms[j].id === wms.wms_id) {
 				return true;
 			}
 		}
@@ -174,7 +193,7 @@
 		for (var i = 0; i < this.wms.length; i++) {
 			var found = false;
 			for (var j = 0; j < this.wms[i].gui_epsg.length; j++) {
-				if (options.srs === this.wms[i].gui_epsg[j]) {
+				if (options.srs === this.wms[i].gui_epsg[j] && this.wms[i].gui_epsg_supported[j]) {
 					found = true;
 					break;
 				}
@@ -187,7 +206,22 @@
 
 		// ...and optionally display a message
 		if (options.displayWarning && ignoredWms.length > 0) {
-			new Mb_warning("The following WMS do not support the current SRS: " + ignoredWms.join(","));
+		
+			var msg = mapMsgObj.srsNotSupported + ": <br><br>";
+
+			for (var key in ignoredWms) {
+				msg += "<b>" + ignoredWms[key].title + "</b><br>";
+			}
+			try {
+				Mapbender.Modules.dialogManager.openDialog({
+					content: msg,
+					modal: false,
+					effectShow: 'puff'
+				});
+			}
+			catch (e) {
+				new Mb_warning(e.message + " " + msg);
+			}
 		}
 
 		// actually set the new values and return extent
@@ -218,7 +252,12 @@
 	for (var i = 0; i < wms.length; i++) {
 		var isValidWms = (wms_index === null) || (wms_index == i);
 		if (isValidWms) {
-			this.wms[index] = wms[i];
+			// MAJOR CHANGE!
+			// formerly, this was a reference!
+			// Now, this is a copy!
+			// Each map object has its own set of WMS.
+			// I expect some things to break :-)
+			this.wms[index] = cloneObject(wms[i]);
 			this.wms[index].mapURL = false;
 			index++;
 		}
@@ -565,6 +604,9 @@
 		if(validLayers.length === 0) {
 			return false;
 		}
+		for (var i = 0; i < validLayers.length; i++) {
+			validLayers[i] = encodeURIComponent(validLayers[i]);			
+		}		
 		var layerNames = validLayers.join(",");
 		
 		url = currentWms.wms_getmap;
@@ -631,7 +673,7 @@
 		url = url.substr(0, url.length-1);
 
 		return url;
-	}
+	};
 	
 	/**
 	 * get all featureInfoRequests
@@ -683,7 +725,7 @@
 			xtenty = parseFloat(bbox[3]) - parseFloat(bbox[1]);
 			scale = (xtenty / this.height) * (mb_resolution * 100);
 		}
-		return parseInt(Math.round(scale));
+		return parseInt(Math.round(scale), 10);
 	};
 	
 	/**
@@ -754,11 +796,12 @@
 			var currentWms = this.wms[ii];
 
 			try {
-				if (!this.requestMapIfSrsNotSupported && isIgnoredWms(currentWms)) {
+				if (this.skipWmsIfSrsNotSupported && isIgnoredWms(currentWms)) {
 					continue;
 				};
 			}
 			catch (e) {
+				new Mb_warning(e.message);
 			}
 
 			if (currentWms.wms_id != wms_id) {
@@ -769,8 +812,14 @@
 			if (mb_log) {
 				var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
 			}
-			var myDivId = this.elementName + "_div_" + ii;          
-			writeTag(this.frameName, myDivId, newMapRequest);
+			var myDivId = this.elementName + "_div_" + ii;  
+			var $wmsDiv = $("#" + myDivId);
+			if ($wmsDiv.size() > 0) {
+				$wmsDiv.remove();
+			}
+			var $newDiv = $(newMapRequest);
+			$("#" + this.elementName + "_maps").append($newDiv);
+
 			var myMapId = this.elementName + "_map_" + ii;
 			eventAfterMapRequest.trigger({"map":this, "myMapId":myMapId});
 			return true;
@@ -804,7 +853,7 @@
 		for(var i=0; i < this.querylayers.length; i++) {
 			this.mb_MapFutureObj[cnt].querylayers[i] = this.querylayers[i];
 		}
-	}
+	};
 	
 	this.setMapRequest = function(){
 		var ret = eventBeforeMapRequest.trigger({
@@ -824,9 +873,10 @@
 			try {
 				if (this.skipWmsIfSrsNotSupported && isIgnoredWms(currentWms)) {
 					continue;
-				};
+				}
 			}
 			catch (e) {
+				new Mb_warning(e.message);
 			}
 			if (!(currentWms.gui_wms_visible > 0)) {
 				continue;
@@ -895,7 +945,7 @@
 		}
 	
 		return newMapRequest;
-	}
+	};
 	
 	this.getWmsIdByTitle = function (title) {
 		for (var i=0; i < this.wms.length; i++) {
@@ -915,6 +965,15 @@
 		return null;
 	};
 
+	this.getWmsById = function (wms_id) {
+		for (var i=0; i< this.wms.length; i++){
+			if(this.wms[i].wms_id == wms_id){
+				return this.wms[i];
+			}
+		}
+		return null;
+	};
+
 	this.removeWms = function (wmsIndex) {
 		var wms_ID = null;
 		var i;
@@ -1012,8 +1071,8 @@
 		}
 		
 		//remove divtag offset
-		clickX -= parseInt(this.getDomElement().style.left);
-		clickY -= parseInt(this.getDomElement().style.top);
+		clickX -= parseInt(this.getDomElement().style.left, 10);
+		clickY -= parseInt(this.getDomElement().style.top, 10);
 		
 		return new Point(clickX, clickY);
 	}



More information about the Mapbender_commits mailing list