ol ---- overlay autoPan的使用

问题:

在使用overlay的autoPan属性时,autoPan:true 失效不起作用;

解决方案:

问题可能是因为在overlay.setPosition(coordinate)前未将该overlay添加到map中;

代码:

  var popup = new ol.Overlay({
                element: document.getElementById('geometryInfo'),
                autoPan: true,
                autoPanMargin: 100,
                positioning: 'top-right'
            });
            map.addOverlay(popup);//将popup添加到map中
            popup.setPosition(coordinates);//给popup附上坐标
原文地址:https://www.cnblogs.com/weixiaoxiang/p/13139231.html