javascript - Openlayer 4选择要素后获取多边形坐标

标签 javascript openlayers

我想在使用interaction.Select选择功能后获取坐标。

我的代码片段:

  var selectf = new ol.interaction.Select({
    layers: [vectorLayer],
     }); 
   map.addInteraction(selectf); 


  selectf.on('select', function(evt) {

//here I want read coordinates of selected feature
}); 

我该怎么做?

最佳答案

在“选择”事件中,您可以使用以下方法从矢量要素获取坐标。

select.on('select', function(event) {
console.log(event.selected[0].getGeometry().getCoordinates());

  });

关于javascript - Openlayer 4选择要素后获取多边形坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43575575/

相关文章:

javascript - 推送未定义的属性

javascript - 如果单击按钮,如何清除我的输入,同时如果输入为空,如何使按钮不可单击?

javascript - 预加载图像然后更改背景javascript

javascript - 打开街道 map ,并回调 OpenLayer

javascript - 解除绑定(bind)不起作用

javascript - 在传单上使用自定义 map 投影

javascript - 这在全局范围内

javascript - 在 2D 空间中模拟 3D 距离的公式?

reactjs - React 中的 Openlayers 弹出窗口 |如何?

javascript - 在不同投影的 basemap 之间切换时如何重新投影矢量图层