[OpenLayers-Users] Export features as json

Paul Meems (Top-X) p.meems at topx-group.nl
Thu Jun 14 05:49:15 PDT 2012


Thanks Wally,

That helped a lot.
I can get geoJson to work:
new OpenLayers.Format.GeoJSON().write(myLayer.features)
but the plain JSON. I'm not interested in the geometries:
new OpenLayers.Format.JSON().write(myLayer.features)
It returns null

--
Paul


2012/6/14 Wally Atkins <wallyatkins at gmail.com>

> Try this openlayers json to write out your object ... That might get
> you what you need:
>
>
> http://dev.openlayers.org/releases/OpenLayers-2.10/doc/apidocs/files/OpenLayers/Format/JSON-js.html
>
>
> On Jun 14, 2012, at 8:16 AM, "Paul Meems (Top-X)" <p.meems at topx-group.nl>
> wrote:
>
> > Hi,
> >
> > I have a website with a map showing a few vectors using WFS and the
> properties of those vectors in a table.
> > I want give the user to opportunity to save the table as a PDF.
> > To do this I want to convert the features to a json string and put that
> in a hidden form element and submit that form to a PHP file that will
> create the PDF.
> >
> > Of course I can loop through the features and create the json string
> manually, but I wonder if I can automatically export to features using
> something like:
> > feature.toJSON().
> >
> > Of course I've used Google but the answers found talked about the other
> way round: JSON to features.
> >
> > Please advice.
> >
> > Thanks,
> >
> > Paul
> >
> > _______________________________________________
> > Users mailing list
> > Users at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/openlayers-users
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120614/06ef23ac/attachment.html>


More information about the Users mailing list