[OpenLayers-Users] using Request.GET vs. Layer with strategy,
protocol, format
Eric Lemoine
eric.lemoine at camptocamp.com
Fri Mar 2 14:29:48 EST 2012
On Friday, March 2, 2012, Scott Chapman <scott at mischko.com> wrote:
> Here's my current code. "A" works. "B" doesn't.
> Is there something else I need to add to make the features actually show
up?
>
> //A:
> var vector_layer = new OpenLayers.Layer.Vector("Stores");
> map.addLayer(vector_layer);
>
> OpenLayers.Request.GET({
> url: "/kiosks_status_geoJSON/",
> headers: {'Accept':'application/json'},
> success: function (req)
> {
> var g = new OpenLayers.Format.GeoJSON();
> var feature_collection = g.read(req.responseText);
> //console.log(feature_collection);
> vector_layer.destroyFeatures();
> vector_layer.addFeatures(feature_collection);
> }
> });
> //vs:
>
> //B:
> var vector_layer = new OpenLayers.Layer.Vector("Stores", {
> strategies: [new OpenLayers.Strategy.Cluster(), new
> OpenLayers.Strategy.Fixed()],
> protocol: new OpenLayers.Protocol.HTTP({
> url: "/kiosks_status_geoJSON/",
> headers: {'Accept':'application/json'},
> format: new OpenLayers.Format.GeoJSON()
> })
> });
> map.addLayer(vector_layer);
What if you remove the cluster strategy?
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120302/93b901ba/attachment.html
More information about the Users
mailing list