根据不同坐标更改地图视口和缩放
我使用 OpenLayers API 作为位于地图服务器(geoServer)上的流式地图的客户端,当我将搜索结果放置在地图上时,视图端口和缩放级别不会改变,我想要缩放到结果集的坐标范围,以进行合适的缩放级别以适应所有结果坐标。
我尝试了以下代码但没有任何价值..
var Newbounds= new OpenLayers.Bounds(); //global var
Newbounds.extend(lonLatMarker); // inside the function of setting the marker data
map.zoomToExtent(Newbounds); // after showing results set of coordinates on the map
i'm using OpenLayers API as a client for streamed maps located on a mapping server (geoServer), when i got a search results placed on the map,the view port and zooming level doesn't change, i want to make a zoom to the coordinates extent of the result set to make a suitable zooming level to fit all resulting coordinates.
I tried the following code but without any value..
var Newbounds= new OpenLayers.Bounds(); //global var
Newbounds.extend(lonLatMarker); // inside the function of setting the marker data
map.zoomToExtent(Newbounds); // after showing results set of coordinates on the map
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
lonLatMarker 是一个什么样的对象?应该是 OpenLayers.LonLat,而不是 OpenLayers.Marker
鉴于您有正确的对象类型,以下代码应该可以工作:
What kind of object is lonLatMarker? Should be OpenLayers.LonLat, not OpenLayers.Marker
Given that you have correct object type, this code should work: