svn commit: r97 - trunk/mapbender/http/javascripts/map.php

christoph at osgeo.org christoph at osgeo.org
Wed Apr 19 09:40:58 EDT 2006


Author: christoph
Date: 2006-04-19 13:40:57+0000
New Revision: 97

Modified:
   trunk/mapbender/http/javascripts/map.php

Log:


Modified: trunk/mapbender/http/javascripts/map.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/map.php?view=diff&rev=97&p1=trunk/mapbender/http/javascripts/map.php&p2=trunk/mapbender/http/javascripts/map.php&r1=96&r2=97
==============================================================================
--- trunk/mapbender/http/javascripts/map.php	(original)
+++ trunk/mapbender/http/javascripts/map.php	2006-04-19 13:40:57+0000
@@ -109,6 +109,18 @@
 function mb_registerloadWmsSubFunctions(stringFunction){
 	mb_loadWmsSubFunctions[mb_loadWmsSubFunctions.length] = stringFunction;
 }
+function mb_removeFunctionFromArray(arrayname,stringFunction){
+	var length = eval(arrayname+".length");
+	for(var i=0; i<length; i++){
+		if(eval(arrayname+"["+i+"]") == stringFunction){
+			var newArray1 = eval(arrayname+".slice(0, "+(i-1)+")");
+			var newArray2 = eval(arrayname+".slice("+(i+1)+", "+length+")");
+			eval(arrayname + " = newArray1.concat(newArray2)");
+			i--;
+			length--;
+		}
+	}
+}
 
 function deleteWmsObject() {
 	wms = new Array();
@@ -188,6 +200,78 @@
       eval(mb_MapObjectSubFunctions[i]);
    }   
 }
+
+function mb_moveWmsById (mapObj_ind, wms_id, toIndex) {
+	return mb_wmsMoveByIndex(mapObj_ind, getWMSIndexById(mapObj_ind, wms_id), toIndex);
+}
+
+function mb_wmsMoveByIndex(mapObj_ind, fromIndex, toIndex) {
+	if (fromIndex != toIndex && fromIndex >= 0 && fromIndex < mb_mapObj[mapObj_ind].wms.length && toIndex >= 0 && toIndex < mb_mapObj[mapObj_ind].wms.length) {
+		var changed = false;
+
+		if (fromIndex > toIndex) {
+			for (var i = fromIndex; i > toIndex ; i--) {
+				var result = mb_swapWmsByIndex(mapObj_ind, i-1, i);
+				if (result == true) changed = true;
+			}
+		}
+		else {
+			for (var i = fromIndex; i < toIndex ; i++) {
+				var result = mb_swapWmsByIndex(mapObj_ind, i, i+1);
+				if (result == true) changed = true;
+			}
+		}
+		return changed;
+	}
+	else {
+		return false;
+	}
+}
+
+function mb_swapWmsById(mapObj_ind, wms1_id, wms2_id) {
+	return mb_swapWmsByIndex(mapObj_ind, getWMSIndexById(mapObj_ind, wms1_id), getWMSIndexById(mapObj_ind, wms2_id));
+}
+
+function mb_swapWmsByIndex(mapObj_ind, indexA, indexB) {
+	if (indexA != indexB && indexA >= 0 && indexA < mb_mapObj[mapObj_ind].wms.length && indexB >= 0 && indexB < mb_mapObj[mapObj_ind].wms.length) {
+		var upper = new Object();
+		upper = mb_mapObj[mapObj_ind].wms[indexA];
+		mb_mapObj[mapObj_ind].wms[indexA] = mb_mapObj[mapObj_ind].wms[indexB];
+		mb_mapObj[mapObj_ind].wms[indexB] = upper;
+		var upperLayers = mb_mapObj[mapObj_ind].layers[indexA];
+		var upperStyles = mb_mapObj[mapObj_ind].styles[indexA];
+		var upperQuerylayers = mb_mapObj[mapObj_ind].querylayers[indexA];
+		mb_mapObj[mapObj_ind].layers[indexA] = mb_mapObj[mapObj_ind].layers[indexB];
+		mb_mapObj[mapObj_ind].styles[indexA] = mb_mapObj[mapObj_ind].styles[indexB];
+		mb_mapObj[mapObj_ind].querylayers[indexA] = mb_mapObj[mapObj_ind].querylayers[indexB];
+		mb_mapObj[mapObj_ind].layers[indexB] = upperLayers;
+		mb_mapObj[mapObj_ind].styles[indexB] = upperStyles;
+		mb_mapObj[mapObj_ind].querylayers[indexB] = upperQuerylayers;
+		return true;
+	}
+	else {
+		return false;
+	}
+}
+
+function mb_moveUpWmsByIndex(mapObj_ind, index) {
+	if (index > 0 && index < wms.length) {
+		return mb_swapWmsByIndex(mapObj_ind, index-1, index);
+	}
+	else {
+		return false;
+	}
+}
+
+function mb_moveDownWmsByIndex(mapObj_ind, index) {
+	if (index >= 0 && index < wms.length-1) {
+		return mb_swapWmsByIndex(mapObj_ind, index, index+1);
+	}
+	else {
+		return false;
+	}
+}
+
 function mb_mapObjaddWMS(obj){
 	var cnt_layers = 0;
 	var cnt_querylayers = 0;
@@ -204,7 +288,11 @@
 	mb_mapObj[ind].wms[mb_mapObj[ind].wms.length] = wms[wms.length-1];
 	mb_mapObj[ind].layers[mb_mapObj[ind].layers.length] = layers;
 	mb_mapObj[ind].styles[mb_mapObj[ind].styles.length] = styles;
-	mb_mapObj[ind].querylayers[mb_mapObj[ind].querylayers.length] = querylayers;   
+	mb_mapObj[ind].querylayers[mb_mapObj[ind].querylayers.length] = querylayers;  
+	for(var i=0; i<mb_loadWmsSubFunctions.length; i++){
+		eval(mb_loadWmsSubFunctions[i]);
+	}
+	return true; 
 }
 //CB
 function mb_mapObjaddWMSwithLayers(obj,layers,querylayers){
@@ -212,12 +300,6 @@
 	var cnt_querylayers = 0;
 	var styles = "";
 	var ind = getMapObjIndexByName(obj);
-	//is the id valid?
-	//for( var i=0; i<(wms.length-1); i++){
-	//	if(parseInt(wms[i].wms_id) >= parseInt(wms[wms.length-1].wms_id)){
-	//		wms[wms.length-1].wms_id = parseInt(mb_mapObj[ind].wms[i].wms_id) + 1;
-	//	}
-	//} 
 	mb_mapObj[ind].wms[mb_mapObj[ind].wms.length] = wms[wms.length-1];
 	mb_mapObj[ind].layers[mb_mapObj[ind].layers.length] = layers;
 	mb_mapObj[ind].styles[mb_mapObj[ind].styles.length] = styles;
@@ -1096,6 +1178,7 @@
 	var ind = getMapObjIndexByName(frameName);
 	mb_mapObj[ind].geom = obj;
 }
+//deprecated!
 function mb_obj2gml(frameName){
 	var ind = getMapObjIndexByName(frameName);	
 	var geom = mb_mapObj[ind].geom;




More information about the Mapbender_commits mailing list