[OpenLayers-Users] understanding and implementing Strategy.BBOX correctly
Puneet Kishor
punk.kish at gmail.com
Mon Oct 15 13:11:42 PDT 2012
I don't quite understand Strategy.BBOX so I would welcome some help. My code is like so
var vec = new OpenLayers.Layer.Vector(
"Vector layer", {
strategies: [new OpenLayers.Strategy.BBOX()],
protocol: new OpenLayers.Protocol.HTTP({
url: "http://path/to/data.json",
params: {
"polygon": map.getExtent()
.transform(
proj.google,
proj.latlng
)
.toGeometry()
.toString()
},
format: new OpenLayers.Format.GeoJSON()
}),
styleMap: new OpenLayers.StyleMap({
"default": style,
"select": new OpenLayers.Style({
strokeColor: "red",
strokeWidth: 2,
graphicZIndex: 2
})
})
}
);
map.addLayer(vec);
vec.setVisibility(true);
Now, the above works well if the map is loaded centered on a view whose `getExtent()` results in data. However, if the map is loaded centered on a view whose extent has no data, then no data are retrieved even when the map is then panned into the right extent. My understanding is that whenever extent changes, a new call is made, so it wouldn't matter if the initial extent didn't have any data. Once I panned/zoomed into the right extent, data would be retrieved and the layer rendered. However, that is not happening. What is the error of my ways, and how do I correct it?
Many thanks,
--
Puneet Kishor
More information about the Users
mailing list