使用 wrapX 在范围内查找矢量源特征

Finding vector source features in extent with wrapX

我目前在 ol.source.Vector 上有一些特征,我想通过在屏幕上绘制一个框 (MultiPolygon) 来找到这些特征。我目前可以使用此功能,但是,如果我移动到下一个渲染世界("spin the globe" 可以这么说),当我在同一组渲染功能上绘制我的框时,我什么也得不到。

示例代码:

var featureSource = new ol.source.Vector({
   url: '/ShinyService/feature/geoJson',
   format: new ol.format.GeoJSON()
});
var featureLayer = new ol.layer.Vector( {
   source: featureSource
});

var myMap = new ol.Map({
    layers: [ featureLayer],
    view: new ol.View({
        minZoom: 3,
        maxZoom: 10
    });
});

//Later within interaction event (draw end)
var boxExtent = box.getGeometry().getExtent();
vectorSource.forEachFeatureInExtent(boxExtent, function(feature){
    foundFeature.push(feature.getId());
});

我目前认为唯一的 "solution" 是不再允许多次渲染世界,但我认为这不是我正在尝试的要求的选项实现。

我目前使用的是 Openlayers v3.18.2

如有任何帮助,我们将不胜感激!

我能够解决我的问题。事实证明,我必须 "wrap" 我的范围坐标才能使其在超过 -180 到 180 边界时正常工作。一旦我这样做了,一切似乎都奏效了。

但是,这感觉像是应该在 Openlayers 中完成的事情,所以我可能会遗漏其他事情。