svn commit: r790 - trunk/mapbender/http/javascripts

christoph at osgeo.org christoph at osgeo.org
Fri Oct 13 05:22:25 EDT 2006


Author: christoph
Date: 2006-10-13 09:22:25+0000
New Revision: 790

Modified:
   trunk/mapbender/http/javascripts/mod_highlight.php
   trunk/mapbender/http/javascripts/wfs.js

Log:
highlight object now has an id. if a new object is instantiatied, it overwrites an existing object that has the same id.

changed on bug report
https://sourceforge.net/tracker/?func=detail&atid=587112&aid=1575744&group_id=88554

Modified: trunk/mapbender/http/javascripts/mod_highlight.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_highlight.php?view=diff&rev=790&p1=trunk/mapbender/http/javascripts/mod_highlight.php&p2=trunk/mapbender/http/javascripts/mod_highlight.php&r1=789&r2=790
==============================================================================
--- trunk/mapbender/http/javascripts/mod_highlight.php	(original)
+++ trunk/mapbender/http/javascripts/mod_highlight.php	2006-10-13 09:22:25+0000
@@ -9,26 +9,27 @@
 ?>
 function Canvas(mapframe, tagname) {
 	this.paint = function(gA) {
-		this.checkTag();
-		for (var q = 0; q < gA.count(); q++) {
-			var m = gA.get(q);
-			var t = m.geomtype;
-			if (t == geomTypePoint)	this.drawGeometry(t,m);
-			else {
-				if (this.isTooSmall(m)){
-					var newMember = new MultiGeometry(geomTypePoint);
-					newMember.addGeometry();
-					newMember.get(-1).addPoint(m.getCenter());
-					this.drawGeometry(geomTypePoint,newMember);
-				}
-				else{
-					if(t == geomTypeLine) this.drawGeometry(t,m);
-					else if(t == geomTypePolygon) this.drawGeometry(t,m);
-					else alert("unknown geomtype");
+		if (this.checkTag()) {
+			for (var q = 0; q < gA.count(); q++) {
+				var m = gA.get(q);
+				var t = m.geomtype;
+				if (t == geomTypePoint)	this.drawGeometry(t,m);
+				else {
+					if (this.isTooSmall(m)){
+						var newMember = new MultiGeometry(geomTypePoint);
+						newMember.addGeometry();
+						newMember.get(-1).addPoint(m.getCenter());
+						this.drawGeometry(geomTypePoint,newMember);
+					}
+					else{
+						if(t == geomTypeLine) this.drawGeometry(t,m);
+						else if(t == geomTypePolygon) this.drawGeometry(t,m);
+						else alert("unknown geomtype");
+					}
 				}
 			}
+			this.canvas.paint();
 		}
-		this.canvas.paint();
 	}
 	
 	this.drawGeometry = function(t,g){
@@ -81,33 +82,34 @@
 	}
 
 	this.checkTag = function () {
-		var isTag = (window.frames[this.mapframe].document.getElementById(this.tagname))?1:0;
-		if(isTag == 0){
-			var draw = window.frames[this.mapframe].document.createElement("div");
-			var tmp = window.frames[this.mapframe].document.getElementsByTagName("body")[0].appendChild(draw);
-			tmp.setAttribute("id",this.tagname);
-			tmp.setAttribute("style","position:absolute;top:0px;left:0px;width:0px;height:0px;z-index:100");
+		if (typeof(window.frames[this.mapframe]) != 'undefined') {
+			var isTag = (window.frames[this.mapframe].document.getElementById(this.tagname))?1:0;
+			if(isTag == 0){
+				var draw = window.frames[this.mapframe].document.createElement("div");
+				var tmp = window.frames[this.mapframe].document.getElementsByTagName("body")[0].appendChild(draw);
+				tmp.setAttribute("id",this.tagname);
+				tmp.setAttribute("style","position:absolute;top:0px;left:0px;width:0px;height:0px;z-index:100");
+			}
+			else {
+				this.clean();
+			}
+			return true;
 		}
+		return false;
 	}
 
 	this.mapframe = mapframe;
 	this.tagname = tagname;
-	this.checkTag();
-	this.canvas = new jsGraphics(this.tagname, window.frames[this.mapframe]);
-	this.canvas.setStroke(3);
+	if (this.checkTag()) {
+		this.canvas = new jsGraphics(this.tagname, window.frames[this.mapframe]);
+		this.canvas.setStroke(3);
+	}
 	this.diameter = 8;
 	this.minWidth = 8;
 	this.lineColor = "#ff0000";
 }
 
-function Highlight(target_array) {
-	this.tagname = 'mod_gaz_draw';
-	this.targets = target_array;
-	this.canvas = new Array();
-	this.gA = new GeometryArray();
-
-	mb_registerPanSubElement(this.tagname);
-	
+function Highlight(target_array, tagname) {
 	this.del = function(m) {
 		this.gA.removeMultiGeometry(m);
 		this.paint();
@@ -125,4 +127,12 @@
 			this.canvas[this.targets[i]].paint(this.gA);
 		}
 	}
+
+	this.tagname = 'mod_gaz_draw'+tagname;
+	this.targets = target_array;
+	this.canvas = new Array();
+	this.gA = new GeometryArray();
+
+	mb_registerPanSubElement(this.tagname);
+	this.paint();
 }

Modified: trunk/mapbender/http/javascripts/wfs.js
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/wfs.js?view=diff&rev=790&p1=trunk/mapbender/http/javascripts/wfs.js&p2=trunk/mapbender/http/javascripts/wfs.js&r1=789&r2=790
==============================================================================
--- trunk/mapbender/http/javascripts/wfs.js	(original)
+++ trunk/mapbender/http/javascripts/wfs.js	2006-10-13 09:22:25+0000
@@ -1,11 +1,11 @@
 <?php 
 require_once("mod_geometryArray.js");
-require_once("mod_highlight.js");
+require_once("mod_highlight.php");
 require_once("wfs_usemap.js");
 ?>
 var digiFrame = "digitize";
+var highlight_tag_id = "digitize";
 var mb_wfs_fetched = new Array();
-
 var	mb_wfs_fetch = new GeometryArray();
 var mb_wfsreq = 0;
 var mb_wfs_tolerance = 8;
@@ -22,7 +22,7 @@
 var mod_usemap_radius = 10;
 var mod_usemap_line_tolerance = 5;
 var useCheckboxForHighlighting = true;
-var highlight = new Highlight(mb_wfs_targets);
+var highlight = new Highlight(mb_wfs_targets, highlight_tag_id);
 
 if (parseInt(useUsemap) == 1) {
 	mb_registerSubFunctions('mod_usemap("")');
@@ -30,6 +30,7 @@
 
 if (useCheckboxForHighlighting) { 
 	mb_registerSubFunctions('highlight.paint()');
+	mb_registerInitFunctions('highlight.paint()');
 }
 
 /*
@@ -155,6 +156,7 @@
 			mb_wfsreq++;
 		}
 	}
+	highlight = new Highlight(mb_wfs_targets, highlight_tag_id);
 	return true;
 }
 




More information about the Mapbender_commits mailing list