Export features as json

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Export features as json

Paul Meems (Top-X)
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Export features as json

wallyatkins
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)" <[hidden email]> 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
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users
Reply | Threaded
Open this post in threaded view
|

Re: Export features as json

Paul Meems (Top-X)
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 <[hidden email]>
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)" <[hidden email]> 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
> [hidden email]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users


_______________________________________________
Users mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/openlayers-users