[OpenLayers-Users] using Request.GET vs. Layer with strategy, protocol, format

Eric Lemoine eric.lemoine at camptocamp.com
Thu Mar 1 00:36:01 EST 2012


On Thursday, March 1, 2012, Scott Chapman wrote:

> The commented out code here works fine.  It kicks off an XHR request
> to my server and fetches back points of interest and plots them.
>
> The uncommented versions here don't work.  The XHR is never kicked off.
>
> I thought these would be equivalent.  Can someone please tell me what
> I'm missing?
>
>
>       //var vector_layer = new OpenLayers.Layer.Vector("Stores");
>       var vector_layer = new OpenLayers.Layer.Vector("Stores", {
>         strategies: [new OpenLayers.Strategy.Cluster()],



The Cluster strategy won't fetch data for you. It is a data manipulation
strategy, not a data fetching strategy. Add a Fixed strategy to the
strategies array and it should work.



>           protocol: new OpenLayers.Protocol.HTTP({
>                     url: "/kiosks_status_geoJSON/",
>                 headers: {'Accept':'application/json'},
>                  format: new OpenLayers.Format.GeoJSON()
>           })
>       });
>       map.addLayer(vector_layer); // <-- This is here in both scenarios.
>
>       //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);
>                       //vector_layer.destroyFeatures();
>                       //vector_layer.addFeatures(feature_collection);
>                       //}
>          //});
>
> Thanks!
> Scott
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org <javascript:;>
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>


-- 
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/20120301/0bc96e61/attachment.html


More information about the Users mailing list