Fork me on GitHub

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附上坐标

 

posted @ 2020-06-16 09:27  weixiaoxiang  阅读(716)  评论(0编辑  收藏  举报