使用openlayers,我如何确保显示所有点列表? [英] with openlayers , how do i make sure a list of points are all displayed?

查看:421
本文介绍了使用openlayers,我如何确保显示所有点列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个OpenLayers地图对象,我已经在图层中添加了标记,并将其添加到地图中。

I have an OpenLayers map object, and I have added markers to a layer, and added it to the map.

但是如何确保所有标记在显示区域?

But how do I make sure all the markers are in the display area?

谢谢,

Gil

推荐答案

为了在地图上显示所有标记

首先,确保在一个图层中包含所有标记。

其次,你需要缩放到标记层中所有标记都被扩展的边界。

要做到这一点,只需要

In order to display all markers on the map
Firstly,make sure you have all markers in one layer.
Secondly,you need to zoom to bound where all markers in marker layer are extended.
To do that,simply

   var bounds = markerLayer.getDataExtent();
   map.zoomToExtent(bounds);
   //has a second parameter that decides to find closest zoom level
   //default is false

请查看 OpenLayers标记层文档

最好的问候

Myra

Best Regards
Myra

这篇关于使用openlayers,我如何确保显示所有点列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆