ZoomToExtent OpenLayers does not scale correctly

I have an openlayers map with a pair of POIs and I want to zoom in so that they all match the map I am making 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 have already noticed: I have to map.zoomTo manually; since map.zoomToExtent really sets the center correctly; but scales to 0 ....

Any ideas as to why it won't calculate scaling for the first time?

+4
source share

All Articles