Openlayer 3 - check if a function is within the power of

I have a list of functions and a vector layer, and I need to know if each function is within the scope of the map or not.

I use openlayers v3.9.0, and in the corresponding documentation there is a function containsExtent()( link ) that has a boolean value. It seems exactly what I'm looking for. But there is an error saying that containsExtent is not a function.

Uncaught TypeError: extent.containsExtent is not a function

code snippet:

// someVectorSource is of type ol.source.Vector
// allMyFeatures is an array of features of type ol.Feature

var extent = someVectorSource.getExtent();
_.each(allMyFeatures, function(feature) {
  if (extent.containsExtent(feature.getGeometry().getExtent())) {
    // do something
  }
});

What is the problem?

If this is the best way, it will be even better to get only those functions that are within, in a single call without repeating through the list.

+4
source share
1 answer

The correct syntax is:

ol.extent.containsExtent(extent, feature.getGeometry().getExtent())

doc, , , ol.Extent . FYI, ol.Extent ol3. 4 . , ol.Extent - .

+9

Source: https://habr.com/ru/post/1619357/


All Articles