[Mapbender-commits] r4676 - branches/2.6/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Sep 22 05:06:38 EDT 2009


Author: christoph
Date: 2009-09-22 05:06:38 -0400 (Tue, 22 Sep 2009)
New Revision: 4676

Modified:
   branches/2.6/http/javascripts/map_obj.js
Log:
http://trac.osgeo.org/mapbender/ticket/515

Modified: branches/2.6/http/javascripts/map_obj.js
===================================================================
--- branches/2.6/http/javascripts/map_obj.js	2009-09-22 08:53:31 UTC (rev 4675)
+++ branches/2.6/http/javascripts/map_obj.js	2009-09-22 09:06:38 UTC (rev 4676)
@@ -78,14 +78,8 @@
 		var clickX, clickY;
 
 		if ($.browser.msie) {
-			if (window.event) {
-				clickX = window.event.clientX;
-				clickY = window.event.clientY;
-			}
-			else {
-				clickX = e.clientX;
-				clickY = e.clientY;
-			}
+			clickX = parseInt(window.event.offsetX, 10);
+			clickY = parseInt(window.event.offsetY, 10);
 		}
 		else{
 			clickX = e.pageX;
@@ -93,11 +87,11 @@
 		}
 
 		var currentPos = null;
-		if (this.type == "DIV") {
+		if (this.type == "DIV" && !$.browser.msie) {
 			var mapDomElement = this.getDomElement();
 			currentPos = new Point(
-				clickX - parseInt(mapDomElement.style.left), 
-				clickY - parseInt(mapDomElement.style.top)
+				clickX - parseInt(mapDomElement.style.left, 10), 
+				clickY - parseInt(mapDomElement.style.top, 10)
 			);
 			// if the mouse position is not on top of the map, return null
 			if (currentPos.x < 0 || currentPos.x > this.width || 
@@ -110,9 +104,18 @@
 				clickX, 
 				clickY
 			);
+
+			// sometimes there are divs within the map (like copyright)
+			// then offsetX and offsetY are not valid.
+			if (window.event.srcElement.tagName.toUpperCase() !== "IMG") {
+				var top = parseInt(window.event.srcElement.style.top, 10);
+				var left = parseInt(window.event.srcElement.style.left, 10);
+				currentPos = currentPos.plus(new Point(left,top));
+			}
+			
 		}
 		return currentPos;
-	}
+	};
 	
 	/**
 	 * converts the extent of the mapobject so that the maximum	extent will be displayed



More information about the Mapbender_commits mailing list