我有一个带有几个POI的openlayers地图,我想缩放所以这些都适合地图,我正在使用以下代码:
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));
现在您可能已经注意到:我必须手动map.zoomTo
;因为map.zoomToExtent
确定了中心的正确性;但缩放到0 ....
关于为什么第一次不能正确计算变焦的任何想法?