Openlayers zoomtoextent 缩放到另一个位置
Openlayers zoomtoextent zooming to another location
我正在尝试放大地图上投影为 EPSG:3857 的边界框。地图应该放大到这里的某个地方:
https://www.google.co.il/maps/place/Netanya/@32.3047285,34.860532,12z/data=!3m1!4b1!4m2!3m1!1s0x151d400493c075d5:0x2cd995be543c3f22 ,但是使用以下代码进入非洲附近海洋中的某个地方。你能告诉我哪里出了问题吗?
bounds = new OpenLayers.Bounds();
bounds.extend(new OpenLayers.LonLat(34.8660822,32.3172887));
bounds.extend(new OpenLayers.LonLat(34.8570271,32.2953077));
bounds.toBBOX();
map.openlayers.zoomToExtent(bounds);
map.openlayers.updateSize();
您必须将边界从 EPSG:4326 (WGS84) 转换为 EPSG:900913 (EPSG:3857)
bounds = new OpenLayers.Bounds();
bounds.extend(new OpenLayers.LonLat(34.8660822,32.3172887));
bounds.extend(new OpenLayers.LonLat(34.8570271,32.2953077));
bounds.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
map.openlayers.zoomToExtent(bounds, true);
我正在尝试放大地图上投影为 EPSG:3857 的边界框。地图应该放大到这里的某个地方:
https://www.google.co.il/maps/place/Netanya/@32.3047285,34.860532,12z/data=!3m1!4b1!4m2!3m1!1s0x151d400493c075d5:0x2cd995be543c3f22 ,但是使用以下代码进入非洲附近海洋中的某个地方。你能告诉我哪里出了问题吗?
bounds = new OpenLayers.Bounds();
bounds.extend(new OpenLayers.LonLat(34.8660822,32.3172887));
bounds.extend(new OpenLayers.LonLat(34.8570271,32.2953077));
bounds.toBBOX();
map.openlayers.zoomToExtent(bounds);
map.openlayers.updateSize();
您必须将边界从 EPSG:4326 (WGS84) 转换为 EPSG:900913 (EPSG:3857)
bounds = new OpenLayers.Bounds();
bounds.extend(new OpenLayers.LonLat(34.8660822,32.3172887));
bounds.extend(new OpenLayers.LonLat(34.8570271,32.2953077));
bounds.transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913"));
map.openlayers.zoomToExtent(bounds, true);