[OpenLayers-Users] using Request.GET vs. Layer with strategy,
protocol, format
Scott Chapman
scott at mischko.com
Fri Mar 2 15:27:27 EST 2012
Found it. Wierd.
Here's the Python that I'm returning for the GeoJSON request:
"type": "FeatureCollection",
"features": [
{"geometry": {
"type": "GeometryCollection",
"geometries": [
{
"type":"Point",
"coordinates":[-98.4375, 39.774769]
#"coordinates":[merc_x(-98.4375), merc_y(39.774769)]
}
]
},
"type": "Feature",
"id": "OpenLayers.Feature.Vector_107",
"properties": {}}
]
}
The commented out portion works with "A" below. The uncommented works
with "B". Somehow the transformation is not needed when using "B".
I don't understand transforms well enough to comment.
Scott
On Fri, Mar 2, 2012 at 11:29 AM, Eric Lemoine
<eric.lemoine at camptocamp.com> wrote:
>
>
> 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
>
More information about the Users
mailing list