[OpenLayers-Dev] How to form URL for to Export and download Selected features as KML formate

mano3688 mano3688 at gmail.com
Thu Oct 20 03:23:47 EDT 2011


I get selected features when i draw polygon using this
polygonSelectFeatureHighlightControl control.
But i want to export selected features as kml when i draw polygon.
			
If i write code like this 
window.open(wfsProtocol.url+'?service=WFS&srs=EPSG:4326&version='+wfsProtocol.version+'&request=GetFeature&outputFormat=OGR-KML&typeName='+stateLayer.name); 
			
i get kml file for full layer,but i need kml file for selected features when
i draw polygon.
			
so please reply which param i want add in the window URL(how to form URL) to
download kml file for selected features.
			
	Thanks to all
			by Manoharan G
My code:
  //My projection
  var projWGS84 = new OpenLayers.Projection("EPSG:4326");
  var projSphericalMercator = new OpenLayers.Projection("EPSG:900913");
  var wfsProtocol = new OpenLayers.Protocol.WFS({
        		url: "http://localhost:8080/geoserver/wfs",
        		featureType:stateLayer.name,
        		featureNS:"http://kcubeconsulting.com/geobrowser",
        		srsName: "EPSG:4326",
        		version: "1.0.0"
				//outputFormat: "OGR-KML"
        	  
        	});
			
			
 
  
  var selectFeaturevectorLayer = new
OpenLayers.Layer.Vector("selectFeaturevectorLayer");
  
   var vectors=new OpenLayers.Layer.Vector("vectors");
  
   //My control for to highlight selected features when i draw polygon
   
  var polygonSelectFeatureHighlightControl=new
OpenLayers.Control.DrawFeature(
       		vectors, OpenLayers.Handler.Polygon,{
       			map:map,
       			eventListeners: {
       	        	"featureadded": function(event) {
       	        		featureHighlightWindow.show();
       	        		event.feature.geometry.transform(new
OpenLayers.Projection("EPSG:900913"),new
OpenLayers.Projection("EPSG:4326"));
       	        		wfsProtocol.read({
       	        			filter: new OpenLayers.Filter.Spatial({
       	        				type: OpenLayers.Filter.Spatial.INTERSECTS,
       	        				value: event.feature.geometry
       	        			}),
       	        			callback: function processSpatialQuery(response)
       	        						{
       	        						
										var feat = response.features;
											var myArr = []; 
											for(var i=0; i<feat.length; ++i) 
											{   
												myArr[i] = feat[i].clone(); 
												     
myArr[i].geometry.transform(projWGS84,projSphericalMercator); 
											} 
											if(selectFeaturevectorLayer.features.length)
											{
												selectFeaturevectorLayer.removeAllFeatures();
											}
											selectFeaturevectorLayer.addFeatures(myArr); 
											
											
											 featureHighlightWindow.hide();
       	        						}
       	        			
       	        		});
       	        	}
   	        	}
			});
			
			
			map.addControl(polygonSelectFeatureHighlightControl);
			polygonSelectFeatureHighlightControl.activate();
			
			

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/How-to-form-URL-for-to-Export-and-download-Selected-features-as-KML-formate-tp6911889p6911889.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.


More information about the Dev mailing list