[OpenLayers-Dev] saving a vector file permanently

David Zwarg dzwarg+ol at azavea.com
Fri Jan 21 09:17:00 EST 2011


Hello Mohammed,

Look at the OpenLayers.Format classes.

Here's a link to the geojson format example:
http://dev.openlayers.org/apidocs/files/OpenLayers/Format/GeoJSON-js.html

You will probably do something like:

var format = new OpenLayers.Format.GeoJSON();

// given that 'layer' is a vector layer attached to the map with some
features:
var jsonstring = format.write( layer.features );

// given that 'txtarea' is an HTML textarea element somewhere in your page
to display the geojson:
txtarea.value = jsonstring;

There's no way to save the file directly via openlayers (opening a "Save
File..." dialog), you have to do some copy & pasting from the browser.

-z

On Fri, Jan 21, 2011 at 8:51 AM, Mohammed Rashad <mohammedrashadkm at gmail.com
> wrote:

> How can I save a OpenLayers.Layer.Vector to a gml, geojson or any openlayer
> supported formats without using
>  WFS or WFS- T( without geoserver,postgis);
>
> Is it possible?
>
> --
> Rashad
>
> _______________________________________________
> Dev mailing list
> Dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20110121/101ba36c/attachment.html


More information about the Dev mailing list