2017-04-23 80 views
0

我想要使用interaction.Select選擇特徵後獲取座標。Openlayer 4在選擇特徵之後獲取多邊形座標

片段我的代碼:

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


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

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

我可怎麼辦呢?

回答

0

在「選擇」事件上,可以使用以下方法從矢量特徵中獲取座標。

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

    }); 
+0

謝謝布魯斯,它的工作。但爲什麼不使用幾何圓? – Rafik73