简体   繁体   中英

OpenLayers 3 Pop-up?

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?

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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