[Mapbender-commits] r7608 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Feb 15 09:07:29 EST 2011


Author: kmq
Date: 2011-02-15 06:07:29 -0800 (Tue, 15 Feb 2011)
New Revision: 7608

Modified:
   trunk/mapbender/http/javascripts/mod_coordsLookup.php
Log:
add highlight to coordinateLookup

Modified: trunk/mapbender/http/javascripts/mod_coordsLookup.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_coordsLookup.php	2011-02-15 11:04:27 UTC (rev 7607)
+++ trunk/mapbender/http/javascripts/mod_coordsLookup.php	2011-02-15 14:07:29 UTC (rev 7608)
@@ -70,6 +70,12 @@
 	}
 }
 ?>
+var standingHighlight = null;
+Mapbender.events.afterMapRequest.register( function(){
+	if(standingHighlight){
+		standingHighlight.paint();
+	}
+});
 var CoordsLookup = function() {
 	var that = this;
 	if(
@@ -212,6 +218,7 @@
 				parseFloat(this.coords.y) + parseFloat(this.coords.perimeter));
 			}
 		}
+		var that = this;
 		var req = new Mapbender.Ajax.Request({
 			url: "../php/mod_coordsLookup_server.php",
 			method: "transform",
@@ -224,13 +231,23 @@
 				
 				var map = Mapbender.modules[options.target];
 				
+				if(standingHighlight !== null){ 
+					standingHighlight.clean();
+				}else{
+					standingHighlight = new Highlight(
+						[options.target],
+						"standingHighlight", 
+						{"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 
+						2);
+				}
 				if (obj.points) {
 					
 					if (obj.points.length === 1) {
-						map.setCenter(new Point(
+						var point = new Point(
 							obj.points[0].x,
 							obj.points[0].y
-						));
+						) 
+						map.setCenter(point);
 					}
 					else if (obj.points.length === 2) {
 						var newExtent = new Extent(
@@ -239,10 +256,22 @@
 							obj.points[1].x,
 							obj.points[1].y
 						);
+						var point0 = new Point(obj.points[0].x,obj.points[0].y);
+						var point1 = new Point(obj.points[1].x,obj.points[1].y);
+						
+						var x = point0.x + (point1.x - point0.x)/2;
+						var y = point0.y + (point1.y - point0.y)/2;
+						var point = new Point(x,y);
 						map.calculateExtent(newExtent);
-						map.setMapRequest();
-						
 					}
+					var ga = new GeometryArray();
+					ga.importPoint({
+						coordinates:[x,y,null]
+					},that.coords.targetProjection)
+					var m = ga.get(-1,-1);
+					standingHighlight.add(m, "#ff0000");
+					standingHighlight.paint();
+					map.setMapRequest();
 				}
 			} 
 		});



More information about the Mapbender_commits mailing list