lat]已经完美实现

时间:2021-11-25 04:01:52

在 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});

}