var map; function initialize(){ map = new OpenLayers.Map ("map_canvas", { controls:[ new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoomBar(), new OpenLayers.Control.Attribution()], maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34), maxResolution: 156543.0399, numZoomLevels: 19, units: 'm', projection: new OpenLayers.Projection("EPSG:900913"), displayProjection: new OpenLayers.Projection("EPSG:4326") }); var layerTilesAtHome = new OpenLayers.Layer.OSM.Osmarender("Osmarender"); layerTilesAtHome.setVisibility(true); layerTilesAtHome.setOpacity(0.5); var data = new OpenLayers.Layer.WFS( "KML Layer ", "Scripts/OpenLayers_Ajax.php",{ projection: new OpenLayers.Projection("EPSG:900913"), displayProjection: new OpenLayers.Projection("EPSG:4326"), units: "m", maxResolution: 156543.0339, maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34), }, {format: OpenLayers.Format.KML, displayProjection: new OpenLayers.Projection("EPSG:900913"), projection: new OpenLayers.Projection("EPSG:4326"), formatOptions: { extractStyles: true, extractAttributes: true}} ); map.addLayers([layerTilesAtHome,data]); selectControl = new OpenLayers.Control.SelectFeature(map.layers[1], {onSelect: onSelect, onUnselect: onUnselect}); selectControl.handlers["feature"].stopDown = false; selectControl.handlers["feature"].stopUp = false; var lonLat = new OpenLayers.LonLat(3,51).transform(new OpenLayers.Projection("EPSG:4326"), map.getProjectionObject()); map.setCenter (lonLat, 5); map.addControl(selectControl); selectControl.activate(); } var selectedFeature; var selectControl; function onPopupClose(evt) { selectControl.unselect(selectedFeature); } function onSelect(feature) { selectedFeature = feature; var content = ""+feature.attributes.mapname+"
Show info & download"; var popup = new OpenLayers.Popup.FramedCloud("chicken", feature.geometry.getBounds().getCenterLonLat(), new OpenLayers.Size(100,100), content, null, true, onPopupClose); feature.popup = popup; map.addPopup(popup); } function onUnselect(feature) { map.removePopup(feature.popup); feature.popup.destroy(); feature.popup = null; }