首页 > Windows开发 > 详细

openlayers3.X 与4.X画圈和画多边形api区别

时间:2018-03-01 11:24:16      阅读:879      评论:0      收藏:0      [点我收藏+]

在 3.X版本中,对于画圈,画多边形不能更好的筛选包含的点,而4.X版本中则只需调用 geom.intersectsCoordinate([lng,lat] 已经完美实现。完整代码如下:

drawselect:function(){
draw.clear();
draw.griddrawLayer = new ol.layer.Vector({
source : draw.griddrawSource,
style : draw.griddrawstyle,
zIndex : 900
});
map.addLayer(draw.griddrawLayer);
draw = new ol.interaction.Draw({
source: draw.griddrawSource,
type: ‘Circle‘
});
map.addInteraction(draw);
draw.on("drawstart", function(evt){
sketch= evt.feature;

}, this);
draw.on("drawend", function(evt) {
map.removeInteraction(draw);
var geom= evt.feature.getGeometry();

vectorSource.forEachFeature(function(_feature){
var layername = _feature.get("layername");
if (layername == "videolayer") {
var lng = _feature.get("lng");
var lat = _feature.get("lat");
if(geom.intersectsCoordinate([lng,lat]) == true){
var name = _feature.get("name");
var code = _feature.get("code");
list.push({"code":code,"name":name});

}

}
});



}, this);


},

openlayers3.X 与4.X画圈和画多边形api区别

原文:https://www.cnblogs.com/cwyql/p/8487212.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!