[Mapbender-commits] r3983 - branches/google_dev/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jun 2 11:29:42 EDT 2009


Author: christoph
Date: 2009-06-02 11:29:42 -0400 (Tue, 02 Jun 2009)
New Revision: 3983

Added:
   branches/google_dev/http/javascripts/mod_google.php
   branches/google_dev/http/javascripts/mod_mapMirror.php
   branches/google_dev/http/javascripts/mod_toggleLayers.php
   branches/google_dev/http/javascripts/mod_wfs_gazetteer_parameterizedSearch.php
Log:


Added: branches/google_dev/http/javascripts/mod_google.php
===================================================================
--- branches/google_dev/http/javascripts/mod_google.php	                        (rev 0)
+++ branches/google_dev/http/javascripts/mod_google.php	2009-06-02 15:29:42 UTC (rev 3983)
@@ -0,0 +1,179 @@
+<?php
+# $Id: mod_center1.php 3382 2009-01-02 10:53:53Z christoph $
+# http://www.mapbender.org/index.php/mod_center1.php
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+echo "var mod_google_target = '".$e_target[0]."';";
+
+$mapsApiUrl = "http://maps.google.com/maps/api/js?sensor=false&key=ABQIAAAAnSxy5UckGSKS1Wxnq6d10RRmYiuLful4T_-5_WDsqgKCFa5YaxSr2GxbtA92UOizu0iI4JvP_23jUw";
+
+readfile($mapsApiUrl);
+
+require(dirname(__FILE__)."/../include/dyn_js.php");
+
+?>
+
+if (typeof CENTER === "undefined") {
+	var CENTER = [50.7376701, 7.0714];
+}
+
+if (typeof MAX_ZOOM_LEVEL === "undefined") {
+	var MAX_ZOOM_LEVEL = 19;
+}
+
+if (typeof MIN_ZOOM_LEVEL === "undefined") {
+	var MIN_ZOOM_LEVEL = 2;
+}
+
+if (typeof ZOOM_LEVEL === "undefined") {
+	var ZOOM_LEVEL = 10;
+}
+
+if (typeof TYPE === "undefined") {
+	var TYPE = "SATELLITE";
+}
+
+if (typeof KEY === "undefined") {
+	var e = new Mb_exception("No key for Google Maps. Please configure the element vars.");
+}
+else {
+
+	mb_mapObj_const.prototype.zoomToLevel = function (currentZoomLevel) {
+		this.google.map.set_zoom(currentZoomLevel);
+		
+		var that = this;
+	
+		var zoomListener = google.maps.event.addListener(this.google.map, "bounds_changed", function () {
+			google.maps.event.removeListener(zoomListener);
+	
+			var newBounds = that.google.map.get_bounds();
+			var newSw = newBounds.getSouthWest();
+			var newNe = newBounds.getNorthEast();
+	
+			that.extent.set(new Point(newSw.lng(), newSw.lat()), new Point(newNe.lng(), newNe.lat()));
+			that.setMapRequest();
+		});			
+	};
+	
+	mb_mapObj_const.prototype.setGoogleMap = function (options) {
+		this.google = {
+			"id" : this.elementName + "-google",
+			"MIN_ZOOM_LEVEL" : MIN_ZOOM_LEVEL,
+			"MAX_ZOOM_LEVEL" : MAX_ZOOM_LEVEL,
+			"isInitialised" : false
+		};
+		
+		var html = "<div id='" + this.google.id + "' " + 
+			"style='position:absolute;top:0px;left:0px;" + 
+			"width:" + this.width + "px;height:" + this.height + "px;" + 
+			"'></div>";
+			
+		$("#" + this.elementName).prepend(html);
+	
+		var disableControlsOptions = {
+			keyboardShortcuts: false,
+			draggable: false,
+			navigationControl: false,
+			scaleControl: false,
+			mapTypeControl: false,
+			disableDefaultUI: true,
+			noResize: true
+		};
+	
+		// get center
+	
+// THIS IS THE CENTER OF WMS 0; MAY RESULT IN A ZOOM LEVEL LIKE 0 OR 1, 
+// WHICH BREAKS THE WMS BBOX 
+//		var latLng = new google.maps.LatLng(this.extent.center.y, this.extent.center.x);
+	
+	    // USE THIS CENTER FOR TESTING!!!!!!!
+		var latLng = new google.maps.LatLng(CENTER[0], CENTER[1]);
+		
+		
+		// calculate zoom level from extent after initialization
+		var temporaryOptions = {
+			zoom : ZOOM_LEVEL,
+			center : latLng
+		};
+		
+		var googleOptions = $.extend(disableControlsOptions, temporaryOptions, options);
+	
+		this.google.map = new google.maps.Map(document.getElementById(this.google.id), googleOptions);
+	
+	
+		mb_registerPanSubElement(this.google.id);
+	
+		var that = this;
+	
+		var initListener = google.maps.event.addListener(this.google.map, "bounds_changed", function () {
+			google.maps.event.removeListener(initListener);
+	
+			var newBounds = that.google.map.get_bounds();
+			var newSw = newBounds.getSouthWest();
+			var newNe = newBounds.getNorthEast();
+			
+			that.extent.set(new Point(newSw.lng(), newSw.lat()), new Point(newNe.lng(), newNe.lat()));
+			that.google.map.isInitialised = true;
+
+			that.setMapRequest();
+		});
+		
+		// THIS MIGHT NOT BE THE BEST WAY TO RESIZE THE GOOGLE MAP
+		// HOWEVER, THERE IS NO API FUNCTION		
+		this.eventResizeMap.register(function () {
+			$("#" + that.google.id).css({
+				"width" : that.width + "px",
+				"height" : that.height + "px"
+			});
+		});
+	
+	};
+	
+	
+	(function () {
+	
+		eventInitMap.register(function () {
+			var map = getMapObjByName(mod_google_target);
+			
+			switch (TYPE) {
+				case "ROADMAP" : 
+					mapTypeId = google.maps.MapTypeId.ROADMAP;
+					break;
+				case "SATELLITE" : 
+					mapTypeId = google.maps.MapTypeId.SATELLITE;
+					break;
+				case "HYBRID" : 
+					mapTypeId = google.maps.MapTypeId.HYBRID;
+					break;
+				case "TERRAIN" : 
+					mapTypeId = google.maps.MapTypeId.TERRAIN;
+					break;
+				default:
+					mapTypeId = google.maps.MapTypeId.SATELLITE;
+					break;
+			}
+
+			var googleOptions = {
+				mapTypeId: mapTypeId,
+				key: KEY
+			};			
+	
+			map.setGoogleMap(googleOptions);
+		});
+	})();
+}
\ No newline at end of file

Added: branches/google_dev/http/javascripts/mod_mapMirror.php
===================================================================
--- branches/google_dev/http/javascripts/mod_mapMirror.php	                        (rev 0)
+++ branches/google_dev/http/javascripts/mod_mapMirror.php	2009-06-02 15:29:42 UTC (rev 3983)
@@ -0,0 +1,143 @@
+<?php
+# $Id: mod_selArea1.php 3391 2009-01-02 14:09:15Z nimix $
+# http://www.mapbender.org/index.php/mod_selArea1.php
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+?>
+(function () {
+<?php
+include '../include/dyn_js.php';
+?>
+
+try {
+	if (wmsIdArray) {}
+}
+catch (e) {
+	wmsIdArray = [];
+}
+
+var mod_mapMirror_elName = "<?php echo $e_id;?>";
+var mod_mapMirror_target1 = "<?php echo $e_target[0]; ?>";
+var mod_mapMirror_target2 = "<?php echo $e_target[1]; ?>";
+
+var affectedItems = [
+	"#zoomIn2",
+	"#zoomOut2",
+	"#pan2",
+	"#selArea2",
+	"#arrow_n_navFrame2",
+	"#arrow_nw_navFrame2",
+	"#arrow_w_navFrame2",
+	"#arrow_sw_navFrame2",
+	"#arrow_s_navFrame2",
+	"#arrow_se_navFrame2",
+	"#arrow_e_navFrame2",
+	"#arrow_ne_navFrame2"
+];
+
+var affectedItemsSelector = affectedItems.join(",");
+
+eventInit.register(function () {
+	var mapObj1 = getMapObjByName(mod_mapMirror_target1);
+	var mapObj2 = getMapObjByName(mod_mapMirror_target2);
+
+	var blockIn1 = [];
+	var blockIn2 = [];
+
+	// block these WMS in map 1
+	for (var i = 0; i < wmsIdArray.length; i++) {
+		var index = mapObj1.getWmsIndexById(wmsIdArray[i]);
+		if (index !== null && mapObj1.wms[index].gui_wms_visible !== 2) {
+			blockIn1.push(index);
+		}
+	}
+
+	// block other WMS in map 2
+	for (var i = 0; i < wms.length; i++) {
+		var found = false;
+		for (var j = 0; j < blockIn1.length; j++) {
+			if (blockIn1[j] === i) {
+				found = true;
+				break;
+			}
+		}
+
+		if (!found && mapObj2.wms[i].gui_wms_visible !== 2) {
+			blockIn2.push(i);
+		}
+	}
+	
+	var blockUnwantedWms = function () {
+		mapObj1.afterMapRequest.register(function () {
+	
+		
+			var selectorArray = [];
+			for (var el in blockIn1) {
+				selectorArray.push("#" + mapObj1.elementName + "_div_" + blockIn1[el]);
+			}
+			var selector = selectorArray.join(",");
+			$(selector).remove();
+		});
+		mapObj2.afterMapRequest.register(function () {
+		
+			var selectorArray = [];
+			for (var el in blockIn2) {
+				selectorArray.push("#" + mapObj2.elementName + "_div_" + blockIn2[el]);
+			}
+			var selector = selectorArray.join(",");
+			$(selector).remove();
+		});
+	};
+
+	blockUnwantedWms();
+
+	$("#" + mod_mapMirror_elName).html("<form><input id='mod_mapMirror_checkbox' type='checkbox' /></form>");
+
+	$("#mod_mapMirror_checkbox").change(function () {
+		if (this.checked === true) {
+			// disable controls
+			$(affectedItemsSelector).css({
+				"visibility":"hidden"
+			});
+
+			// mirror map extent of map 1 in map 2
+			mapObj1.afterMapRequest.register(function () {
+				var ext1 = mapObj1.extent;
+				mapObj2.extent = ext1;
+				mapObj2.setMapRequest();	
+			});
+			
+			// initial mirroring
+			mapObj1.afterMapRequest.trigger();
+		}
+		else {
+			// remove mirroring
+			mapObj1.afterMapRequest = new MapbenderEvent();
+			
+			// re-add blocking
+			blockUnwantedWms();
+
+			// enable controls
+			$(affectedItemsSelector).css({
+				"visibility":"visible"
+			});
+		}
+	});
+	
+});
+}());
\ No newline at end of file

Added: branches/google_dev/http/javascripts/mod_toggleLayers.php
===================================================================
--- branches/google_dev/http/javascripts/mod_toggleLayers.php	                        (rev 0)
+++ branches/google_dev/http/javascripts/mod_toggleLayers.php	2009-06-02 15:29:42 UTC (rev 3983)
@@ -0,0 +1,84 @@
+<?php
+# $Id: mod_selArea1.php 3391 2009-01-02 14:09:15Z nimix $
+# http://www.mapbender.org/index.php/mod_selArea1.php
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+?>
+(function () {
+<?php
+include '../include/dyn_js.php';
+?>
+
+try {
+	if (layerData) {}
+}
+catch (e) {
+	layerData = {};
+}
+
+var mod_toggleLayers_elName = "<?php echo $e_id;?>";
+
+
+function findLayerInWmsAndSetVisibility (map, wmsArray, visibility) {
+	if (typeof(wmsArray) !== "object") {
+		return;
+	}
+	for (var wmsId in wmsArray) {
+		var index = map.getWmsIndexById(wmsId);
+		if (index === null) {
+			continue;
+		}
+		for (var i in wmsArray[wmsId]) {
+			var name = wmsArray[wmsId][i];
+			map.wms[index].handleLayer(name, "visible", visibility);
+		}
+	}
+}
+
+eventInit.register(function () {
+
+	var checkBoxId = mod_toggleLayers_elName + "_checkbox";
+	$("#" + mod_toggleLayers_elName).html("<form><input id='" + checkBoxId + "' type='checkbox' /></form>");
+
+	$("#" + checkBoxId).change(function () {
+		for (var el in layerData) {
+			if (typeof(el) !== "string") {
+				continue;
+			}
+
+			var map = getMapObjByName(el);
+			if (map === false) {
+				continue;
+			}
+
+			var layerVisibility;
+			if (typeof(layerData[el].on) !== "undefined") {
+				layerVisibility = this.checked === true ? 1 : 0;
+				findLayerInWmsAndSetVisibility(map, layerData[el].on, layerVisibility);
+			}
+
+			if (typeof(layerData[el].off) !== "undefined") {
+				layerVisibility = this.checked === false ? 1 : 0;
+				findLayerInWmsAndSetVisibility(map, layerData[el].off, layerVisibility);
+			}
+			map.setMapRequest();
+		}
+	});
+	
+});
+}());
\ No newline at end of file

Added: branches/google_dev/http/javascripts/mod_wfs_gazetteer_parameterizedSearch.php
===================================================================
--- branches/google_dev/http/javascripts/mod_wfs_gazetteer_parameterizedSearch.php	                        (rev 0)
+++ branches/google_dev/http/javascripts/mod_wfs_gazetteer_parameterizedSearch.php	2009-06-02 15:29:42 UTC (rev 3983)
@@ -0,0 +1,29 @@
+<?php 
+# $Id: mod_wfs_gazetteer_client.php 3818 2009-03-27 08:25:43Z verenadiewald $
+# maintained by http://www.mapbender.org/index.php/User:Verena Diewald
+# http://www.mapbender.org/index.php/WFS_gazetteer
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+?>
+},
+parameterizedSearch : function (value) {
+	var valueArray = value;
+	if (typeof value === "number" || typeof value === "string") {
+		valueArray = [value];
+	}
+	window.frames.gazetteerWFS.parameterizedSearch(20, "Verfahren", valueArray);
\ No newline at end of file



More information about the Mapbender_commits mailing list