[OpenLayers-Users] Re: Example of GeoJson fetch via HTTP?
scott at mischko.com
Tue Feb 28 17:41:21 EST 2012
Here's how you do this:
var vector_layer = new OpenLayers.Layer.Vector();
success: function (req)
var g = new OpenLayers.Format.GeoJSON();
var feature_collection = g.read(req.responseText);
If anyone has any pointers, I'd be happy to hear them!
On Mon, Feb 27, 2012 at 7:36 PM, Scott Chapman <scott at mischko.com> wrote:
> I've got a map and want to add a layer to it from a bunch of GeoJSON
> formatted features that I can fetch from the server at
> /kiosks_status_geoJSON/. The server will return JSON format output.
> Can someone point me to an example of how to do this or lay it out for me?
> Some of my points of confusion include:
> 1) The docs (http://dev.openlayers.org/releases/OpenLayers-2.11/doc/apidocs/files/OpenLayers/Format/GeoJSON-js.html)
> say that a GeoJSON Format.read() will deserialize a GeoJSON string,
> but the example
> already been deserialized. Is it smart enough to deal with both
> 2) The overall flow of things. I think I should make a Request.GET
> to fetch the URL, an event handler to deal with the response having a
> Format.geoJSON.read() the result and vector_layer.addFeatures on that.
> I'd love to see an example of this setup.
More information about the Users