简体   繁体   English

OpenLayers 3弹出窗口?

[英]OpenLayers 3 Pop-up?

In OpenLayers 2 I was using the OpenLayers.Popup.FramedCloud object. 在OpenLayers 2中,我使用的是OpenLayers.Popup.FramedCloud对象。 Under OpenLayers 3, this object is apparently gone, so I have replicated the functionality using an overlay. 在OpenLayers 3下,该对象显然消失了,因此我已使用覆盖图复制了功能。 One feature of the older style popup that I haven't been able to replicate however is the automatic positioning. 自动定位是我无法复制的较旧样式弹出窗口的功能之一。 That is, under OpenLayers 2 it would change where the pop-up opened relative to the map point depending on where it had the most room. 也就是说,在OpenLayers 2中,它将根据相对于地图点的最大空间来更改弹出窗口相对于地图点打开的位置。 So it might be above, below, to the right, or to the left of the point. 因此它可能在该点的上方,下方,右侧或左侧。 How can I replicate this functionality in OpenLayers 3? 如何在OpenLayers 3中复制此功能?

Not exactly what you are asking for, but ol.Overlay takes an option autoPan which will pan the map so that the popup is visible. 并非完全符合您的要求,但是ol.Overlay带有一个autoPan选项,它将平移地图以便显示弹出窗口。

  var overlay = new ol.Overlay({
    ...
    autoPan: true,
    autoPanAnimation: {
      duration: 250
    }
  });

http://openlayers.org/en/master/examples/popup.html http://openlayers.org/en/master/examples/popup.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM