[OpenLayers-Dev] Export vector layer featuers as .kml and download
that .kml file
mano3688
mano3688 at gmail.com
Thu Oct 13 06:38:49 EDT 2011
Hello sir,
Now i trying to create .kml file but i don't how to create .kml
file and download that .kml file,Please tell me if you know anybody.I am
using wms and vector layer on the map.Features will be added when i click on
the map .
i want export vector layers as .kml file and how to download that file.
I write my partial code here,
map = new OpenLayers.Map('map');
map.addControl(new OpenLayers.Control.LayerSwitcher());
// create Google Mercator layers
googleLayer = new OpenLayers.Layer.Google("Google Streets Map",{
'sphericalMercator': true
});
osmLayer = new OpenLayers.Layer.OSM("Open Street Map");
stateLayer=new OpenLayers.Layer.WMS(
"States", "http://localhost:8080/geoserver/wms",
{
layers: 'kcube:States',
transparent: true,
styles: '',
format:'image/png',
tiled: 'true',
srs: 'EPSG:4326'
},
{
buffer: 0,
isBaseLayer: false
}
);
layer=stateLayer.name;
var select = new OpenLayers.Layer.Vector("Selection");
map.addLayers([googleLayer, osmLayer,stateLayer,select]);
var control = new OpenLayers.Control.GetFeature({
protocol: OpenLayers.Protocol.WFS.fromWMSLayer(stateLayer),
multipleKey: "shiftKey",
toggleKey: "ctrlKey"
});
control.events.register("featureselected", this, function(e) {
if(select.features.length)
{
select.removeAllFeatures();
}
select.addFeatures([e.feature]);
var kmlFormat = new OpenLayers.Format.KML(
{
internalProjection:new OpenLayers.Projection("EPSG:900913"),
externalProjection: new OpenLayers.Projection("EPSG:4326"),
extractAttributes:true
}
);
var kmlString=kmlFormat.write(select.features, true);
});
map.addControl(control);
control.activate();
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Export-vector-layer-featuers-as-kml-and-download-that-kml-file-tp6888418p6888418.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
More information about the Dev
mailing list