检查点是否在OpenLayers 3中的多边形内

阿德莫吉特·卡西米

当我在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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章