当我在OpenLayers地图中绘制多边形时,我想知道标记是否在多边形内。我搜索了OpenLayers API,但没有找到解决方案。
您可以在此链接中看到我的完整代码。
我的印象是我必须修改此功能:
function addInteraction() {
var value = typeSelect.value;
if (value !== 'None') {
draw = new ol.interaction.Draw({
source: vectorSource,
type: /** @type {ol.geom.GeometryType} */ (typeSelect.value)
});
map.addInteraction(draw);
draw.on('drawend',function(e){
//Here
});
}
}
我怎样才能做到这一点?
您为ol.geom.Geometry提供了一个方法' intersectsCoordinate '。
因此,该代码如下所示:
var polygonGeometry = e.feature.getGeometry();
var coords = iconFeature.getGeometry().getCoordinates();
polygonGeometry.intersectsCoordinate(coords)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句