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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Dec 6 08:46:41 EST 2007


Author: christoph
Date: 2007-12-06 08:46:35 -0500 (Thu, 06 Dec 2007)
New Revision: 1896

Modified:
   trunk/mapbender/http/javascripts/geometry.js
Log:
allows to display an icon as a point highlight

Modified: trunk/mapbender/http/javascripts/geometry.js
===================================================================
--- trunk/mapbender/http/javascripts/geometry.js	2007-12-06 12:21:39 UTC (rev 1895)
+++ trunk/mapbender/http/javascripts/geometry.js	2007-12-06 13:46:35 UTC (rev 1896)
@@ -1033,7 +1033,14 @@
 				var p = realToMap(mapframe,g.get(i).get(0));
 				if (p.x + diameter < mb_mapObj[mapObjInd].width && p.x - diameter > 0 &&
 					p.y + diameter < mb_mapObj[mapObjInd].height && p.y - diameter > 0) {
-					drawCircle(p.x-1, p.y-1, diameter,col);
+					// if the point contains a link to an icon, display the icon
+					g.e.setElement("Mapbender:icon", "../img/indicator_wheel.gif");
+					if (g.e.getElementValueByName("Mapbender:icon")) {
+						displayIcon(g.e.getElementValueByName("Mapbender:icon"), p.x, p.y);
+					}
+					else {
+						drawCircle(p.x-1, p.y-1, diameter,col);
+					}
 				}
 			}
 			else if(t==geomType.line || t==geomType.polygon) {
@@ -1105,6 +1112,25 @@
 	};
 
 	/**
+	 * Displays an icon in the mapframe
+	 * 
+	 * @private
+	 * @param {String} url link to the image
+	 * @param {Float} x x coordinate within the map frame
+	 * @param {Float} y y coordinate within the map frame
+	 */
+	var displayIcon = function (url, x, y) {
+		var newImg = document.createElement("img");
+		newImg.src = url;
+		newImg.style.position = "absolute";
+
+		// center the image at x, y
+		newImg.style.top = y - Math.round(newImg.height/2);
+		newImg.style.left = x - Math.round(newImg.width/2);
+		that.canvasDivTag.getTag().appendChild(newImg);
+	}
+	
+	/**
 	 * This is the {@link DivTag} that contains the output by {@link jsGraphics}.
 	 * 
 	 * @type DivTag



More information about the Mapbender_commits mailing list