OpenLayers zoomToExtent does not zoom correctly
I have an openlayers map with a couple of POI, an开发者_Python百科d I want to zoom so these all fit the map, which I'm doing with the following code:
var bbox = new OpenLayers.Bounds(
<?php echo $this->box->getSmallestLongitude() ?>,
<?php echo $this->box->getSmallestLatitude() ?>,
<?php echo $this->box->getLargestLongitude() ?>,
<?php echo $this->box->getLargestLatitude() ?>
).transform(map.displayProjection, map.projection);
map.zoomToExtent(bbox);
//normally zoom is auto, but for some reason it zooms to 0...
//manual zoom looks like a correct workaround
map.zoomTo(map.getZoomForExtent(bbox));
Now as you may already have noticed: I have to map.zoomTo
manually; since the map.zoomToExtent
does set the center correct; but zooms to 0....
Any ideas as to why it won't calculate the zoom correct the first time?
精彩评论