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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jun 3 12:31:49 EDT 2009


Author: christoph
Date: 2009-06-03 12:31:49 -0400 (Wed, 03 Jun 2009)
New Revision: 3995

Modified:
   branches/google_dev/http/javascripts/map_obj.js
   branches/google_dev/http/javascripts/mod_box1.js
   branches/google_dev/http/javascripts/mod_dragMapSize.php
Log:


Modified: branches/google_dev/http/javascripts/map_obj.js
===================================================================
--- branches/google_dev/http/javascripts/map_obj.js	2009-06-03 16:29:51 UTC (rev 3994)
+++ branches/google_dev/http/javascripts/map_obj.js	2009-06-03 16:31:49 UTC (rev 3995)
@@ -133,46 +133,52 @@
 	 * converts the extent of the mapobject so that the maximum	extent will be displayed
 	 */
 	this.calculateExtent = function(ext){
-		if (typeof this.google !== "undefined") {
-
-			if (this.google.map.get_zoom() < MAX_ZOOM_LEVEL) {
-				// get extent and fit Google map
-				var sw = new google.maps.LatLng(ext.min.y, ext.min.x);
-				var ne = new google.maps.LatLng(ext.maxy, ext.max.x);
-				var latLngBounds = new google.maps.LatLngBounds(sw, ne);
-				this.google.map.fitBounds(latLngBounds);
-			}
-			else {
-				var latLng = new google.maps.LatLng(ext.center.y, ext.center.x);
-				this.google.map.set_center(latLng);
-			}
-
-			var zoomByRectangleListener = google.maps.event.addListener(this.google.map, "bounds_changed", function () {
-				google.maps.event.removeListener(zoomByRectangleListener);
-
-				// check zoom level
-				if (that.google.map.get_zoom() < MIN_ZOOM_LEVEL) {
-					that.google.map.set_zoom(MIN_ZOOM_LEVEL);
+		try {
+			
+			if (typeof this.google !== "undefined") {
+	
+				if (this.google.map.get_zoom() < MAX_ZOOM_LEVEL) {
+					// get extent and fit Google map
+					var sw = new google.maps.LatLng(ext.min.y, ext.min.x);
+					var ne = new google.maps.LatLng(ext.maxy, ext.max.x);
+					var latLngBounds = new google.maps.LatLngBounds(sw, ne);
+					this.google.map.fitBounds(latLngBounds);
 				}
-				else if (that.google.map.get_zoom() > MAX_ZOOM_LEVEL) {
-					that.google.map.set_zoom(MAX_ZOOM_LEVEL);
+				else {
+					var latLng = new google.maps.LatLng(ext.center.y, ext.center.x);
+					this.google.map.set_center(latLng);
 				}
-
-				var newBounds = that.google.map.get_bounds();
-				var newSw = newBounds.getSouthWest();
-				var newNe = newBounds.getNorthEast();
+	
+				var zoomByRectangleListener = google.maps.event.addListener(this.google.map, "bounds_changed", function () {
+					google.maps.event.removeListener(zoomByRectangleListener);
+	
+					// check zoom level
+					if (that.google.map.get_zoom() < MIN_ZOOM_LEVEL) {
+						that.google.map.set_zoom(MIN_ZOOM_LEVEL);
+					}
+					else if (that.google.map.get_zoom() > MAX_ZOOM_LEVEL) {
+						that.google.map.set_zoom(MAX_ZOOM_LEVEL);
+					}
+	
+					var newBounds = that.google.map.get_bounds();
+					var newSw = newBounds.getSouthWest();
+					var newNe = newBounds.getNorthEast();
+					
+					// set bounding box
+					that.extent.set(new Point(newSw.lng(), newSw.lat()), new Point(newNe.lng(), newNe.lat()));
+	
+					// set center to center of rectangle
+					that.extent.set(ext.center);
+					
+					that.setMapRequest();
+										
+				});
 				
-				// set bounding box
-				that.extent.set(new Point(newSw.lng(), newSw.lat()), new Point(newNe.lng(), newNe.lat()));
-
-				// set center to center of rectangle
-				that.extent.set(ext.center);
-				
-				that.setMapRequest();
-									
-			});
+				return;			
+			}
+		}
+		catch (e) {
 			
-			return;			
 		}
 		var relation_px_x = this.getWidth() / this.getHeight();
 		var relation_px_y = this.getHeight() / this.getWidth();
@@ -428,10 +434,15 @@
 	};
 	
 	this.zoomFull = function () {
-		if (typeof this.google !== "undefined") {
-			this.zoomToLevel(this.google.MIN_ZOOM_LEVEL);
-			return;
+		try {
+			if (typeof this.google !== "undefined") {
+				this.zoomToLevel(this.google.MIN_ZOOM_LEVEL);
+				return;
+			}
 		}
+		catch (e) {
+			
+		}
 
 /*		
 		if (this.restrictedExtent) {
@@ -470,76 +481,81 @@
 			factor = 1 / factor;
 		}
 
-		// When a Google Map is included, 
-		// * update the zoom level
-		// * calculate the extent
-		// * repaint with new extent
-		if (typeof this.google !== "undefined") {
-			var currentZoomLevel = this.google.map.get_zoom();
-			if (factor > 1 && currentZoomLevel < this.google.MAX_ZOOM_LEVEL) {
-				currentZoomLevel++;
-			}
-			else if (factor < 1 && currentZoomLevel > this.google.MIN_ZOOM_LEVEL) {
-				currentZoomLevel--;
-			}
-			else {
-				if (typeof x !== "undefined" && typeof y !== "undefined") {
-					this.setCenter(new Point(x, y));
-					this.setMapRequest();
+		try {
+			// When a Google Map is included, 
+			// * update the zoom level
+			// * calculate the extent
+			// * repaint with new extent
+			if (typeof this.google !== "undefined") {
+				var currentZoomLevel = this.google.map.get_zoom();
+				if (factor > 1 && currentZoomLevel < this.google.MAX_ZOOM_LEVEL) {
+					currentZoomLevel++;
 				}
+				else 
+					if (factor < 1 && currentZoomLevel > this.google.MIN_ZOOM_LEVEL) {
+						currentZoomLevel--;
+					}
+					else {
+						if (typeof x !== "undefined" && typeof y !== "undefined") {
+							this.setCenter(new Point(x, y));
+							this.setMapRequest();
+						}
+						return;
+					}
+				this.zoomToLevel(currentZoomLevel);
 				return;
 			}
-			this.zoomToLevel(currentZoomLevel);
 		}
-		else {
-			var extent = this.getExtentInfos();
-			var distx = extent.maxx - extent.minx;
-			var disty = extent.maxy - extent.miny;
+		catch (e) {
 			
-			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;
-			// Check if ext is within restricted extent
-			// If not, calculate a new extent according
-			// to restricted extent.
-			/*
-			var relation_px_x = this.getWidth() / this.getHeight();
-			var relation_px_y = this.getHeight() / this.getWidth();
-			if ( this.restrictedExtent ) {
-				if ( minx  < this.restrictedExtent.minx ) {  
-		            minx = this.restrictedExtent.minx;
-		            maxx = minx + (relation_px_x * new_disty);
-		        }
-		        if ( miny < this.restrictedExtent.miny ) {
-		            miny = this.restrictedExtent.miny;
-		            maxy = miny + (relation_px_y * new_distx);
-		        }
-		        if ( maxx > this.restrictedExtent.maxx ) {
-		            maxx = this.restrictedExtent.maxx;
-		            minx = maxx - (relation_px_x * new_distx);
-		        }
-		        if ( maxy > this.restrictedExtent.maxy ) {
-		            maxy = this.restrictedExtent.maxy;
-		            miny = maxy - (relation_px_y * new_disty);
-		        }
-			}
-			*/
-			
-			this.setExtent(minx, miny, maxx, maxy);
-			this.setMapRequest();
 		}
+		var extent = this.getExtentInfos();
+		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;
+		// Check if ext is within restricted extent
+		// If not, calculate a new extent according
+		// to restricted extent.
+		/*
+		var relation_px_x = this.getWidth() / this.getHeight();
+		var relation_px_y = this.getHeight() / this.getWidth();
+		if ( this.restrictedExtent ) {
+			if ( minx  < this.restrictedExtent.minx ) {  
+	            minx = this.restrictedExtent.minx;
+	            maxx = minx + (relation_px_x * new_disty);
+	        }
+	        if ( miny < this.restrictedExtent.miny ) {
+	            miny = this.restrictedExtent.miny;
+	            maxy = miny + (relation_px_y * new_distx);
+	        }
+	        if ( maxx > this.restrictedExtent.maxx ) {
+	            maxx = this.restrictedExtent.maxx;
+	            minx = maxx - (relation_px_x * new_distx);
+	        }
+	        if ( maxy > this.restrictedExtent.maxy ) {
+	            maxy = this.restrictedExtent.maxy;
+	            miny = maxy - (relation_px_y * new_disty);
+	        }
+		}
+		*/
+		
+		this.setExtent(minx, miny, maxx, maxy);
+		this.setMapRequest();
 	};
 	
 	var performUnknownCalculation = function (value) {
@@ -876,18 +892,24 @@
 	
 	this.setMapRequest = function(){
 		// optionally, paint a Google map
-		if (this.google !== "undefined" && !this.google.skipRequest) {
-			if (this.google.map.isInitialised === true) {
-				var latLng = new google.maps.LatLng(this.extent.center.y, this.extent.center.x);
-				this.google.map.set_center(latLng);
+		try {
+		
+			if (this.google !== "undefined" && !this.google.skipRequest) {
+				if (this.google.map.isInitialised === true) {
+					var latLng = new google.maps.LatLng(this.extent.center.y, this.extent.center.x);
+					this.google.map.set_center(latLng);
+				}
+				else {
+					setTimeout(function(){
+						that.setMapRequest();
+					}, 100);
+					return;
+				}
 			}
-			else {
-				setTimeout(function(){
-					that.setMapRequest();
-				}, 100);
-				return;
-			}
 		}
+		catch (e) {
+			
+		}
 		
 		var functionName = 'setMapRequest';
 		

Modified: branches/google_dev/http/javascripts/mod_box1.js
===================================================================
--- branches/google_dev/http/javascripts/mod_box1.js	2009-06-03 16:29:51 UTC (rev 3994)
+++ branches/google_dev/http/javascripts/mod_box1.js	2009-06-03 16:31:49 UTC (rev 3995)
@@ -180,9 +180,16 @@
 		
 		if(coords.length > 2){
 			map.calculateExtent(new Extent(coords[0],coords[1],coords[2],coords[3]));
-			if (typeof map.google === "undefined") {
+			
+			try {
+				if (typeof map.google !== "undefined") {
+					return;
+				}
 				setMapRequest(mb_zF);
 			}
+			catch (e) {
+				
+			}
 		}
 		else{
 			zoom(mb_zF,true,1.0,coords[0], coords[1]);

Modified: branches/google_dev/http/javascripts/mod_dragMapSize.php
===================================================================
--- branches/google_dev/http/javascripts/mod_dragMapSize.php	2009-06-03 16:29:51 UTC (rev 3994)
+++ branches/google_dev/http/javascripts/mod_dragMapSize.php	2009-06-03 16:31:49 UTC (rev 3995)
@@ -113,13 +113,17 @@
 	targetObject.eventResizeMap.trigger();
 
 	// google maps automatically draws the map after the canvas is resized
-	if (typeof targetObject.google !== "undefined") {
-		targetObject.google.skipRequest = true;
+	try {
+		if (typeof targetObject.google !== "undefined") {
+			targetObject.google.skipRequest = true;
+			targetObject.setMapRequest();
+			targetObject.google.skipRequest = false;
+			return;
+		}
 	}
+	catch (e) {
+	}
 	targetObject.setMapRequest();
-	if (typeof targetObject.google !== "undefined") {
-		targetObject.google.skipRequest = false;
-	}
 }
 
 function mod_dragMapSize_drag(e){



More information about the Mapbender_commits mailing list