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

Scott Chapman scott at mischko.com
Thu Mar 1 14:47:38 EST 2012


Cool! That fetched the XHR request.  Nothing showed up on the map!  >sigh< :)


On Wed, Feb 29, 2012 at 9:36 PM, Eric Lemoine
<eric.lemoine at camptocamp.com> wrote:
>
>
> 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
>> 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
>


More information about the Users mailing list