[OpenLayers-Users] using Request.GET vs. Layer with strategy,
protocol, format
Scott Chapman
scott at mischko.com
Wed Feb 29 18:46:09 EST 2012
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()],
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
More information about the Users
mailing list