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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Jul 13 09:23:44 EDT 2010


Author: kmq
Date: 2010-07-13 13:23:44 +0000 (Tue, 13 Jul 2010)
New Revision: 6596

Modified:
   trunk/mapbender/http/javascripts/geometry.js
Log:
modified drawing logic to return a reference to the drawn node

Modified: trunk/mapbender/http/javascripts/geometry.js
===================================================================
--- trunk/mapbender/http/javascripts/geometry.js	2010-07-13 13:08:43 UTC (rev 6595)
+++ trunk/mapbender/http/javascripts/geometry.js	2010-07-13 13:23:44 UTC (rev 6596)
@@ -1715,6 +1715,7 @@
  	this.drawGeometry = function(t,g,col){
  		var mapframeWidth = map.width;
 		var mapframeHeight = map.height;
+		var node = null;
 	
 		if(t == geomType.point) {
 			var poiIcon = g.e.getElementValueByName("Mapbender:icon");
@@ -1741,14 +1742,14 @@
 					// if the point contains a link to an icon, display the icon
 					if (poiIcon) {
 						if (isNaN(poiWidth) || isNaN(poiHeight)) {
-							displayIcon(poiIcon, px, py, poiOffsetX, poiOffsetY);
+							node = displayIcon(poiIcon, px, py, poiOffsetX, poiOffsetY);
 						}
 						else {
-							displayIcon(poiIcon, px, py, poiOffsetX, poiOffsetY, poiWidth, poiHeight);
+							node = displayIcon(poiIcon, px, py, poiOffsetX, poiOffsetY, poiWidth, poiHeight);
 						}
 					}
 					else {
-						drawCircle(px-1, py-1, diameter,col);
+						node = drawCircle(px-1, py-1, diameter,col);
 					}
 				}
 			}
@@ -1792,6 +1793,7 @@
 				}
 				//				}
 				var canvasPath = canvas.path(path);
+				node = canvasPath.node;
 				if (t == geomType.polygon) {
 					canvasPath.attr({
 						"fill": col,
@@ -1848,6 +1850,7 @@
 		else {
 			var e = new Mb_exception("class Canvas: function drawGeometry: unknown geomType " + t);
 		}
+	return node;
 	};
 
 	/**
@@ -1935,6 +1938,7 @@
 	 * @param {Float} y y coordinate within the map frame
 	 */
 	var displayIcon = function (url, x, y, offsetX, offsetY, width, height) {
+		var node = null;
 		if (typeof offsetX !== "number" || isNaN(offsetX)) {
 			offsetX = -40;
 		}
@@ -1947,23 +1951,28 @@
 
 		if (typeof Raphael !== "undefined") {
 			if (width !== undefined && height !== undefined) {
-				canvas.image(url, newImgLeft, newImgTop, width, height);
+				var img = canvas.image(url, newImgLeft, newImgTop, width, height);
+				node = img.node;
 			}
 			else {
 				var $img = $('<img src="'+url+'" />');
 				var width = $img.attr('width')||24;
 				var height = $img.attr('height')||24;
-				canvas.image(url, newImgLeft, newImgTop, width, height);
+				var img = canvas.image(url, newImgLeft, newImgTop, width, height);
+				node = img.node;
 				
 			}
 		}
 		else {
-			$(that.canvasDivTag.getTag()).html("<img name='mapSymbol' id='mapSymbol' src='" + 
+			var $img = $("<img title='mapSymbol' class='mapSymbol' src='" + 
 			url + "' style='position:absolute;top:" + newImgTop + ";left:" + newImgLeft + 
 			";" + (width !== undefined ? "width:" + width + "px;" : "") +
 			(height !== undefined ? "height:" + height + "px;" : "") +
-			";z-index:100;display:none'/>").children("img").show();
+			";z-index:100;display:none'/>")
+			$(that.canvasDivTag.getTag()).html($img).children("img").show();
+			node = $img.get(0);
 		}
+		return node;
 	};
 	
 	/**
@@ -2031,23 +2040,33 @@
  * @param {GeometryArray} gA the geometries that will be drawn
  */
 Canvas.prototype.paint = function(gA) {
+	var nodes = [];
+	var node = null;
 	for (var q = 0; q < gA.count(); q++) {
 		var m = gA.get(q);
 		var t = m.geomType;
 		var col = m.color;
 		if (t == geomType.point) {
-			this.drawGeometry(t,m,col);
+			node =this.drawGeometry(t,m,col);
+			nodes.push(node);
 		}
 		else {
 			if (this.isTooSmall(m)){
 				var newMember = new MultiGeometry(geomType.point);
 				newMember.addGeometry();
 				newMember.get(-1).addPoint(m.getCenter());
-				this.drawGeometry(geomType.point,newMember,col);
+				node = this.drawGeometry(geomType.point,newMember,col);
+				nodes.push(node);
 			}
 			else{
-				if(t == geomType.line) {this.drawGeometry(t,m, col);}
-				else if(t == geomType.polygon) {this.drawGeometry(t,m,col);}
+				if(t == geomType.line) {
+					node = this.drawGeometry(t,m, col);
+					nodes.push(node);
+				}
+				else if(t == geomType.polygon) {
+					node = this.drawGeometry(t,m,col);
+					nodes.push(node);
+				}
 				else {
 					var e = new Mb_exception("class Canvas: function paint: unknown geomType" + t);				
 				}
@@ -2057,6 +2076,7 @@
 	if (typeof Raphael === "undefined") {
 		this.getCanvas().paint();
 	}
+	return nodes;
 };
 
 /**
@@ -2071,6 +2091,7 @@
  * @param {Integer} the line width of the jsGraphics lines
  */
 function Highlight(aTargetArray, aTagName, aStyle, aLineWidth) {
+	var nodes = [];
 	/**
 	 * removes a {@link MultiGeometry} object from the geometry Array
 	 *
@@ -2148,7 +2169,7 @@
 			if (typeof(canvas[i]) == 'undefined') {
 				canvas[i] = new Canvas(targets[i], tagname + i, style, lineWidth);
 			}
-			canvas[i].paint(gA);
+			nodes = canvas[i].paint(gA);
 		}
 	};
 
@@ -2189,6 +2210,11 @@
 			}
 		}
 	};
+
+		
+	this.getNodes = function(){
+		return nodes;
+	};
 	
 	var lineWidth = aLineWidth;
 	var tagname = 'mod_gaz_draw'+aTagName;



More information about the Mapbender_commits mailing list