[Mapbender-commits] r6277 - trunk/mapbender/http/plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jun 16 09:43:23 EDT 2010


Author: kmq
Date: 2010-06-16 13:43:23 +0000 (Wed, 16 Jun 2010)
New Revision: 6277

Modified:
   trunk/mapbender/http/plugins/mb_loadkmlgeorss.js
Log:
added basic dialog, changed some handling when multiple feeds are present

Modified: trunk/mapbender/http/plugins/mb_loadkmlgeorss.js
===================================================================
--- trunk/mapbender/http/plugins/mb_loadkmlgeorss.js	2010-06-16 12:37:16 UTC (rev 6276)
+++ trunk/mapbender/http/plugins/mb_loadkmlgeorss.js	2010-06-16 13:43:23 UTC (rev 6277)
@@ -76,6 +76,7 @@
 
 var that = this;
 that.feeds = [];
+that.$popup = $('<div></div>').dialog({autoOpen : false, height: 500});
 
 $('<div id="'+ options.id +'_dialog"><label>GeoRSS <input type="radio" name="type" value="GeoRSS" checked="checked"/></label>'+
 	 '<label>KML<input type="radio" name="type" value="KML"></label><br />'+
@@ -112,7 +113,6 @@
 							var $map = $('#mapframe1').mapbender();
 							var markers = [];
 							var title = "";
-							var popup = null;
 							$("table", $dialog).remove();
 							var $table = $("<table><thead><tr><th class='labelName'>"+ translatedI18nObject.labelName  +"</th></tr></thead><tbody></tbody></table>");
 
@@ -135,42 +135,51 @@
 									"z-index": "80" },1);
 								for(var i =0; i < geomArray.count(); i++){
 									g = geomArray.get(i);
-
 									// per feature stuff
-									//g.e.setElement("Mapbender:icon", options.img.url); //? where to get, let the server do it ?
-									//g.e.setElement("Mapbender:iconOffsetX", options.img.offset.x);
-									//g.e.setElement("Mapbender:iconOffsetY", options.img.offset.y);
-									//g.e.setElement("Mapbender:iconZIndex", options.img.offset.y);
-
+									g.e.setElement("Mapbender:icon","http://localhost:8080/trunk/http/img/marker/red.png");
+									// THIS NEEDS AN OFFSET!
+									title = g.e.getElementValueByName("title");
+									name = g.e.getElementValueByName("name");
+									// kml uses name
+									title = name? name : title;
+									description = g.e.getElementValueByName("description");
+									$row = $("<tr><td>"+ title  +"</td></tr>");
+									$row.css("cursor","pointer");
+									$row.click((function(title,description){
+										return function(){
+											$("*",that.$popup).remove();
+											that.$popup.append($("<div><h1>"+title+"</h1><p>"+description +"</p></div>")).dialog('open');
+										};
+									})(title,description));
+									$("tbody",$table).append($row);
 									h.add(g);
-
+									title = "";
+									name = "";
 								}
 								h.paint();
 								map.events.afterMapRequest.register(function () {
 									h.paint();
 								});
 
-								var index = that.feeds.push({
-									url: url,
+								that.feeds[url] = {
 									geomArray: geomArray,
-									highlight: h,
-								});
-								index--; //push returns the length
+									highlight: h
+								};
 
 
 
 							}
+
 							var $tableDialog = $("<div></div>").dialog({
 								width: "450",
 								height: "500",
 								position: options.position,
-								beforeclose: function(){
-									h.clean();
-									for(var i in markers){
-										markers[i].remove();
-									}	
-
-								},
+								beforeclose: (function(url){
+									return function(){
+										delete that.feeds[url];
+										h.clean();
+										};
+									})(url),
 								buttons: {"Close": function(){
 										$(this).dialog('close');
 										$(this).dialog('destroy');
@@ -178,6 +187,7 @@
 								}
 							});
 							$tableDialog.append($table);
+							
 							Mapbender.languageId;
 							$table.dataTable({"bJQueryUI": true ,
 								"oLanguage":{
@@ -228,22 +238,42 @@
 				clickPoint:	clickPoint.toText(),
 				geometries: requestGeometries
 				},
-			callback: function(result, success, message){
+			callback: (function(geomArray){ return function(result, success, message){
 				if(!success){
 					return;
 				}
 				// this is basically an onclick handler, !intersects means
 				// the click didn't happen on the polygon
-				if(!result.geometries){
+				if(!result.geometries || result.geometries.length < 1){
 					return;
 				}
-				for(var i in geometries){
+
+				$("*",that.$popup).remove();
+				var $tabs = $("<ul></ul>");
+				// this iterates over an object where the keys are _not_ the incremential
+				// basically a sparse array. therefore I cannot be used to count the entries in the object
+				// this is why j is used
+				var j = 0;
+				for(i in result.geometries){
 					//TODO: add the popup handler
+					var g = geomArray.get(i);
+					title = g.e.getElementValueByName("title");
+					description = g.e.getElementValueByName("description");
+					$tabs.append('<li><a href="#rsspopup_'+ i +'">'+ title + '</a></li>');
+					that.$popup.append('<div id="rsspopup_'+ i +'"><h1>'+ title +'</h1><p>'+ description +'</p></h1>');
+					j++;
 				}
+				if(j > 1){
+					that.$popup.prepend($tabs);
+					$tabs.tabs();
+				}
+				that.$popup.dialog('open');
+			
 
-			}
+			}})(feed.geomArray)
 			});
 			req.send();
+			requestGeometries = [];
 		}
 	});
 });



More information about the Mapbender_commits mailing list