Is it possible to write and save a KML from OpenLayers? Anyone know of an example of exporting one?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
You can export only the vector features to KML.
UPDATE
In order to force the browser to download the KML string as a KML file you need to send that string back to the server-side so it can be returned to the browser as a file to download.
You haven't specified what language/platform/etc you are using on the server-side But this is what i did in C#.
I created a handler which takes in a the filename from the querystring and the KML from a textarea form.
KMLDownload.ashx:
Then from my javascript side i simply call this to initiate the download:
Here's some JQuery action to save:
IF you are using Openlayers 3 or 4, you will find that the syntax of previous (2012) answers does not work anymore.
This does: