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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon May 10 08:00:04 EDT 2010


Author: kmq
Date: 2010-05-10 08:00:04 -0400 (Mon, 10 May 2010)
New Revision: 6146

Modified:
   trunk/mapbender/http/plugins/mb_loadkmlgeorss.js
Log:
show balloon popup after click in list 

Modified: trunk/mapbender/http/plugins/mb_loadkmlgeorss.js
===================================================================
--- trunk/mapbender/http/plugins/mb_loadkmlgeorss.js	2010-05-10 11:57:07 UTC (rev 6145)
+++ trunk/mapbender/http/plugins/mb_loadkmlgeorss.js	2010-05-10 12:00:04 UTC (rev 6146)
@@ -85,38 +85,27 @@
 								return;
 							}
 
-							var map = $('#mapframe1').mapbender();
+							var $map = $('#mapframe1').mapbender();
 							var markers = [];
+							var title = "";
+							var popup = null;
 							$("table", $dialog).remove();
 							var $table = $("<table><thead><tr><th>Name</th></tr></thead><tbody></tbody></table>");
 							if(data.features){
 								var markeroptions = {width: "19px", height: "34px"};
 								for(var i in data.features){
-									if(data.features[i].properties.title){
-										$row = $("<tr><td>"+ data.features[i].properties.title  +"</td></tr>");
-									}else if(data.features[i].properties.name){
-										$row = $("<tr><td>"+ data.features[i].properties.name  +"</td></tr>");
-									}
+									title = data.features[i].properties.title || data.features[i].properties.name || "untitled";
+									$row = $("<tr><td>"+ title +"</td></tr>");
 									if(data.features[i].properties.iconurl){
 										markeroptions.img = {url: data.features[i].properties.iconurl, offset: {x:0,y:0}} ;
 									}
-									$row.click((function(description){
-										return function(){
-											$('<div><div style="max-height:400px;max-width:300px;">'+ description + '</div></div>').dialog({autoOpen: true, 
-												buttons: { "OK": function(){ $(this).dialog("close");$(this).dialog("destroy"); } }
-												 } );
-										}
-									})(data.features[i].properties.description));
-									$("tbody",$table).append($row);
-									
 									var x = data.features[i].geometry.coordinates[0];	
 									var y = data.features[i].geometry.coordinates[1];	
-									
-									point = new Mapbender.Point(x,y);
-									
-									$("tr:last-child",$table).css("cursor","pointer");
-									$("tr:last-child", $table).click((function(x,y){	
+									$row.click((function(feature){
 										return function(){
+											var x = feature.geometry.coordinates[0];	
+											var y = feature.geometry.coordinates[1];	
+													
 											var buffer =  new Mapbender.Point(options.buffer,options.buffer);
 											var a = new Mapbender.Point(x,y);
 											a = a.minus(buffer);
@@ -124,10 +113,28 @@
 											var b = new Mapbender.Point(x,y);
 											b = b.plus(buffer);
 
-											map.calculateExtent( new Mapbender.Extent(a,b));	
-											map.setMapRequest();
-									}})(x,y));
-									marker = new Mapbender.Marker(point,map, markeroptions);
+											$map.calculateExtent( new Mapbender.Extent(a,b));	
+											$map.setMapRequest();
+											
+											var offset = $('#'+options.target).offset();
+											var mapPoint = $map.convertRealToPixel(new Mapbender.Point(x,y));
+											if(popup) {popup.hide();}
+											if(mb_popup){
+												popup = new mb_popup({left: mapPoint.x + offset.left,
+												top: mapPoint.y + offset.top,
+												balloon: true,
+												html: feature.properties.description,
+												title :feature.properties.title || feature.properties.name || "untitled"
+												});
+												popup.show();
+											}
+										}
+									})(data.features[i]));
+									$row.css("cursor","pointer");
+									$("tbody",$table).append($row);
+									
+									point = new Mapbender.Point(x,y);
+									marker = new Mapbender.Marker(point,$map, markeroptions);
 									markers.push(marker);
 								
 								}



More information about the Mapbender_commits mailing list