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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon May 10 10:43:50 EDT 2010


Author: kmq
Date: 2010-05-10 10:43:49 -0400 (Mon, 10 May 2010)
New Revision: 6151

Modified:
   trunk/mapbender/http/plugins/mb_loadkmlgeorss.js
Log:
reorganized a little bit

Modified: trunk/mapbender/http/plugins/mb_loadkmlgeorss.js
===================================================================
--- trunk/mapbender/http/plugins/mb_loadkmlgeorss.js	2010-05-10 13:25:39 UTC (rev 6150)
+++ trunk/mapbender/http/plugins/mb_loadkmlgeorss.js	2010-05-10 14:43:49 UTC (rev 6151)
@@ -69,7 +69,8 @@
 						var $dialog = $(this);
 						$dialog.dialog("close");
 				
-						if($("input:checked",$dialog).val() == "GeoRSS"){
+						var format = $("input:checked",$dialog).val();
+						if( format == "GeoRSS"){
 							var endpointURL = "../php/geoRSSToGeoJSON.php";
 						}else{
 							var endpointURL = "../php/kmlToGeoJSON.php";
@@ -92,6 +93,9 @@
 							$("table", $dialog).remove();
 							var $table = $("<table><thead><tr><th>Name</th></tr></thead><tbody></tbody></table>");
 							if(data.features){
+								// we always transform _from_ 4326 geoRSS and KML use this as their default
+								var projSrc = new Proj4js.Proj('EPSG:4326');
+								var projDest = new Proj4js.Proj($map.epsg);
 								var markeroptions = {width: "19px", height: "34px"};
 								for(var i in data.features){
 									title = data.features[i].properties.title || data.features[i].properties.name || "untitled";
@@ -101,41 +105,55 @@
 									}
 									var x = data.features[i].geometry.coordinates[0];	
 									var y = data.features[i].geometry.coordinates[1];	
-									$row.click((function(feature){
+									point = Proj4js.transform(projSrc, projDest,new Mapbender.Point(x,y));
+									marker = new Mapbender.Marker(point,$map, markeroptions);
+									markers.push(marker);
+
+									$row.click((function(feature, marker, markerIndex){
 										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);
+											var buffer = new Mapbender.Point(options.buffer,options.buffer);
+											var a = Proj4js.transform(projSrc,projDest,new Mapbender.Point(x,y));
 											a = a.minus(buffer);
 
-											var b = new Mapbender.Point(x,y);
+											var b = Proj4js.transform(projSrc,projDest,new Mapbender.Point(x,y));
 											b = b.plus(buffer);
 
 											$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"
+											var mapPoint = $map.convertRealToPixel(Proj4js.transform(projSrc,projDest, new Mapbender.Point(x,y)));
+											marker.remove();
+											point = Proj4js.transform(projSrc, projDest, new Mapbender.Point(x,y));
+											var markeroptions = {width: "19px", height: "34px", img:{url: "../img/marker/orange.png", offset: new Point(-10,-34)}};
+											var highlightmarker = new Mapbender.Marker(point,$map, markeroptions);
+									
+											$('<div style="max-height:20em; max-width:20em">'+ feature.properties.description + "</div>").dialog({
+												title: feature.properties.title || feature.properties.name || "untitled",
+												position: [mapPoint.x+offset.left+20, mapPoint.y + offset.top+20 ],
+												autoOpen: true,
+												buttons : {"Close":function(){
+													$(this).dialog("close");
+													}},
+												close: function(){
+													highlightmarker.remove();
+													point = Proj4js.transform(projSrc, projDest, new Mapbender.Point(x,y));
+													var markeroptions = {width: "19px", height: "34px"};
+													if(feature.properties.iconurl){
+														markeroptions.img = {url: feature.properties.iconurl, offset: {x:0,y:0}} ;
+													}
+													marker = new Mapbender.Marker(point,$map, markeroptions);
+													markers.push(marker);
+												}
 												});
-												popup.show();
-											}
 										}
-									})(data.features[i]));
+									})(data.features[i], marker));
 									$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