[Mapbender-commits] r3798 - in branches: . pseudoSlippy/http/javascripts pseudoSlippy/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Sun Mar 22 16:13:17 EDT 2009


Author: christoph
Date: 2009-03-22 16:13:16 -0400 (Sun, 22 Mar 2009)
New Revision: 3798

Added:
   branches/pseudoSlippy/
Modified:
   branches/pseudoSlippy/http/javascripts/map_obj.js
   branches/pseudoSlippy/http/javascripts/mod_box1.js
   branches/pseudoSlippy/http/javascripts/mod_pan.php
   branches/pseudoSlippy/http/javascripts/mod_zoomIn1.php
   branches/pseudoSlippy/lib/exception.js
Log:
pseudo slippy map

Copied: branches/pseudoSlippy (from rev 3797, trunk/mapbender)

Modified: branches/pseudoSlippy/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js	2009-03-20 14:31:03 UTC (rev 3797)
+++ branches/pseudoSlippy/http/javascripts/map_obj.js	2009-03-22 20:13:16 UTC (rev 3798)
@@ -213,6 +213,7 @@
 		}
 	}
 	var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
+	this.oldExtent = null;
 	
 	this.calculateExtent(wmsExtent);
 
@@ -289,6 +290,9 @@
 	 * @param {Object} direction
 	 */
 	this.pan = function (direction) {
+		var extent = this.getExtentInfos();
+		this.oldExtent = extent;
+
 		var arrayBBox = this.extent.split(",");
 		var minx = parseFloat(arrayBBox[0]);
 		var miny = parseFloat(arrayBBox[1]);
@@ -296,8 +300,10 @@
 		var maxy = parseFloat(arrayBBox[3]);
 		var xtentx = maxx - minx;
 		var xtenty =  maxy - miny;
-		var factor = 0.5;
+		var factor = 0.4;
 		
+//		var oldPoint = this.convertRealToPixel(new Point(minx, miny));
+		
 		switch (direction) {
 			case "NW" :
 				minx -= (xtentx * factor); 
@@ -340,12 +346,18 @@
 				maxx -= (xtentx * factor);
 				break;
 		}
+//		var newPoint = this.convertRealToPixel(new Point(minx, miny));
+//		var diff = oldPoint.minus(newPoint);
+//		this.arrangeElements(diff.y, diff.x);
+
 		this.extent = minx + "," + miny + "," + maxx + "," + maxy;
 		this.setMapRequest();
 		
 	};
 	
 	this.zoomFull = function () {
+		var extent = this.getExtentInfos();
+		this.oldExtent = extent;
 		
 		for (var i = 0; i < this.wms[0].gui_epsg.length; i++) {
 			if (this.epsg == this.wms[0].gui_epsg[i]) {
@@ -369,7 +381,7 @@
 	 * @param {float} y center to y-position
 	 */
 	this.zoom = function(in_, factor, x, y){
-		factor = parseFloat(factor);
+		var factor = parseFloat(factor);
 		if (!in_) {
 			factor = 1 / factor;
 		}
@@ -379,11 +391,14 @@
 		var disty = extent.maxy - extent.miny;
 		
 		
+		
 		if (x && y) {
 			var centerx = parseFloat(x);
 			var centery = parseFloat(y);
 		}
 		else {
+			// the image is already moved if x and y are given
+			this.oldExtent = extent;
 			var centerx = extent.minx + distx / 2;
 			var centery = extent.miny + disty / 2;
 		}
@@ -719,11 +734,17 @@
 	}
 	
 	this.setMapRequest = function(){
-		var functionName = 'setMapRequest';
-		
+		if (this.oldExtent) {
+			this.arrangeElements();
+		}
+
+		firstMapReady = false;
+
 		var ret = eventBeforeMapRequest.trigger({
 				map: this
-			}, "AND");
+			}, "AND"
+		);
+
 		if (ret === false) {
 			return true;
 		}
@@ -732,6 +753,19 @@
 		
 		var newMapRequest = "";
 		
+		// once the first map is ready, the old ones will be deleted
+		removeOldMaps = function () {
+			for (var ii = 0; ii < that.wms.length; ii++) {
+				var myDivId = that.elementName + "_div_" + ii;          
+				var $div = $('#' + myDivId);
+				if (!firstMapRequest) {
+					while ($div.children().size() > 1) {
+						$div.children().eq(0).remove();
+					}
+				}
+			}
+		}
+		
 		for (var ii = 0; ii < this.wms.length; ii++) {
 			var currentWms = this.wms[ii];
 		
@@ -743,8 +777,9 @@
 			newMapRequest += getLayerHtmlCode(ii);
 			
 		}
-		writeTag(this.frameName, this.elementName+"_maps", newMapRequest);
+//		writeTag(this.frameName, this.elementName+"_maps", newMapRequest);
 
+		
 		eventAfterMapRequest.trigger({
 			"map": this,
 			"myMapId": myMapId.join(",")
@@ -752,7 +787,46 @@
 	};
 
 	var that = this;
+	
+	var firstMapReady = false;
+	var firstMapRequest = true;
+	
+	var removeOldMaps = function () {
+		// is written in setMapRequest
+		return null;
+	};
 
+	this.arrangeElements = function () {
+		var oldLL = new Point(this.oldExtent.minx, this.oldExtent.miny);
+		var oldUR = new Point(this.oldExtent.maxx, this.oldExtent.maxy);
+		
+		var oldLLPix = this.convertRealToPixel(oldLL);
+		var oldURPix = this.convertRealToPixel(oldUR);
+
+		var left = oldLLPix.x;
+		var top = oldURPix.y;
+		var width = oldURPix.x - oldLLPix.x;
+		var height = oldLLPix.y - oldURPix.y;
+
+		var mapDiv = $("#" + this.elementName + "_maps div");
+		mapDiv.animate({
+			left: left + "px", 
+			top: top + "px"
+		}, 
+		{
+			duration: "slow"
+		});
+
+		var mapImg = $("#" + this.elementName + "_maps div img");
+		mapImg.animate({
+			width: width + "px",
+			height: height + "px"
+		}, 
+		{
+			duration: "slow"
+		});
+	};
+
 	var getLayerHtmlCode = function (ii) {
 		var currentWms = that.wms[ii];
 	
@@ -779,21 +853,40 @@
 			}
 		}
 	
+
 		var imageString = "";
 		if (newMapURL) {
 			imageString = "<img id='"+myMapId+"' name='mapimage' ";
-			imageString += "src='" + newMapURL + "' ";
 			imageString += "width='"+that.width+"' ";
 			imageString += "height='"+that.height+"' ";
-			imageString += "border='0'>";	
+			imageString += "border='0' />";	
 		}
 	
 		var newMapRequest = "<div id='"+myDivId+"' ";
 		newMapRequest += "style=\"position:absolute; top:0px; left:0px; ";
 		newMapRequest += "z-index:" + ii + ";" + opacityString + "\">";
-		newMapRequest += imageString;
 		newMapRequest += "</div>";   
 	
+		if ($('#' + myDivId).size() === 0) {
+			$('#' + that.elementName+"_maps").append($(newMapRequest));
+		}
+		var $div = $('#' + myDivId);
+		$(imageString).attr('src', newMapURL).load(function () {
+			$div.css({
+					left: "0px", top: "0px"
+				}).append( $(this) );
+			if (!firstMapReady) {
+				mb_arrangeElement(that.frameName, that.elementName+"_maps", 0, 0);
+				for(var i=0; i<mb_PanSubElements.length; i++){
+					mb_arrangeElement(that.frameName, mb_PanSubElements[i], 0, 0);
+				} 
+
+				firstMapReady = true;
+				removeOldMaps();
+				firstMapRequest = false;
+			}			
+		});
+
 		that.mapURL[ii]= newMapURL;	
 		currentWms.mapURL = newMapURL;
 	

Modified: branches/pseudoSlippy/http/javascripts/mod_box1.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_box1.js	2009-03-20 14:31:03 UTC (rev 3797)
+++ branches/pseudoSlippy/http/javascripts/mod_box1.js	2009-03-22 20:13:16 UTC (rev 3798)
@@ -14,7 +14,7 @@
 var mb_offset_bottom = 0;
 var mb_offset_left = 0;
 
-function  mod_box_start(e){
+function mod_box_start(e){
 	mb_boxMapObj = getMapObjByName(mb_isBF);
 	mb_isActive = true;
 	mb_boxMapObj.getMousePos(e);
@@ -176,10 +176,11 @@
 
 function mod_box_setValidClipping(coords){
 	if(coords.length > 2){
-		mb_calculateExtent(mb_zF,coords[0],coords[1],coords[2],coords[3]);
-		setMapRequest(mb_zF);
+		mb_boxMapObj.oldExtent = mb_boxMapObj.getExtentInfos();
+		mb_boxMapObj.calculateExtent(new Extent(coords[0],coords[1],coords[2],coords[3]));
+		mb_boxMapObj.setMapRequest();
 	}
 	else{
-		zoom(mb_zF,true,1.0,coords[0], coords[1]);
+		mb_boxMapObj.zoom(true, 1.0, coords[0], coords[1]);
 	}
 }

Modified: branches/pseudoSlippy/http/javascripts/mod_pan.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_pan.php	2009-03-20 14:31:03 UTC (rev 3797)
+++ branches/pseudoSlippy/http/javascripts/mod_pan.php	2009-03-22 20:13:16 UTC (rev 3798)
@@ -93,13 +93,14 @@
 	var el = mod_pan_MapObj.getDomElement();
 	var center_x = (width / 2)  - dif_x;
 	var center_y = (height / 2) - dif_y;
-	var real_center = makeClickPos2RealWorldPos(mod_pan_target,center_x, center_y);   
+	var real_center = mod_pan_MapObj.convertPixelToReal(new Point(center_x, center_y));   
 
-	mb_arrangeElement(mod_pan_MapObj.frameName, mod_pan_target+"_maps", 0, 0);
-	for(var i=0; i<mb_PanSubElements.length; i++){
-		mb_arrangeElement(mod_pan_MapObj.frameName, mb_PanSubElements[i], 0, 0);
-	} 
-   zoom(mod_pan_target,false, 1.0, real_center[0], real_center[1]);   
+//	mb_arrangeElement(mod_pan_MapObj.frameName, mod_pan_target+"_maps", 0, 0);
+//	for(var i=0; i<mb_PanSubElements.length; i++){
+//		mb_arrangeElement(mod_pan_MapObj.frameName, mb_PanSubElements[i], 0, 0);
+//	} 
+	mod_pan_MapObj.oldExtent = null;
+	mod_pan_MapObj.zoom(false, 1.0, real_center.x, real_center.y);   
 }
 function mod_pan_move_map(){
 	var dif_x = mb_end_x - mb_start_x;

Modified: branches/pseudoSlippy/http/javascripts/mod_zoomIn1.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_zoomIn1.php	2009-03-20 14:31:03 UTC (rev 3797)
+++ branches/pseudoSlippy/http/javascripts/mod_zoomIn1.php	2009-03-22 20:13:16 UTC (rev 3798)
@@ -27,8 +27,10 @@
 
 var $zoomin1Button = $("#"+zoomin1Id);
 
+var zoomin1_mapObj = getMapObjByName("<?php  echo $e_target[0];  ?>");
+
 $zoomin1Button.click(function () {
-	zoom("<?php  echo $e_target[0];  ?>", true, 2.0);
+	zoomin1_mapObj.zoom(true, 2.0);
 });
 
 function mod_zoomIn1_init(obj){

Modified: branches/pseudoSlippy/lib/exception.js
===================================================================
--- trunk/mapbender/lib/exception.js	2009-03-20 14:31:03 UTC (rev 3797)
+++ branches/pseudoSlippy/lib/exception.js	2009-03-22 20:13:16 UTC (rev 3798)
@@ -51,26 +51,31 @@
 				alert(message);
 			}
 			else if (log_js == "console") {
-				if ($.browser.msie) {
-					try {
-						mb_ajax_post('../php/mb_js_exception.php', {level:level,text:message});
-					}
-					catch(e) {
-						alert(e + ": " + message);
-					}
-					
-				}
-				else {
+				
+				if (!$.browser.msie && window.console) {
 					if (level == "warning") {
 						console.warn("%s", message);
 					}
-					else if (level == "error") {
-						console.error("%s", message);
-					}
 					else {
-						console.log("%s", message);
+						if (level == "error") {
+							console.error("%s", message);
+						}
+						else {
+							console.log("%s", message);
+						}
 					}
 				}
+				else {
+					try {
+						mb_ajax_post('../php/mb_js_exception.php', {
+							level: level,
+							text: message
+						});
+					} 
+					catch (e) {
+						alert(e + ": " + message);
+					}
+				}
 			}
 		}
 	};



More information about the Mapbender_commits mailing list