OpenLayers 3 Pop-up?

时间:2015-12-04 21:19:02

标签: javascript openlayers-3

In OpenLayers 2 I was using the OpenLayers.Popup.FramedCloud object. Under OpenLayers 3, this object is apparently gone, so I have replicated the functionality using an overlay. 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. 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?

1 个答案:

答案 0 :(得分:2)

不完全符合您的要求,但ol.Overlay会选择autoPan选项,它会平移地图以便弹出窗口可见。

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

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