visibleFeaturesAtPoint$2 method

NSArray visibleFeaturesAtPoint$2(
  1. CGPoint point, {
  2. NSSet? inStyleLayersWithIdentifiers,
  3. NSPredicate? predicate,
})

Returns an array of rendered map features that intersect with a given point, restricted to the given style layers and filtered by the given predicate.

Each object in the returned array represents a feature rendered by the current style and provides access to attributes specified by the relevant map content sources. The returned array includes features loaded by MLNShapeSource and MLNShapeSource objects but does not include anything from MLNRasterTileSource objects, or from video or canvas sources, which are unsupported by this SDK.

The returned features are drawn by a style layer in the current style. For example, suppose the current style uses the Mapbox Streets source, but none of the specified style layers includes features that have the maki property set to bus. If you pass a point corresponding to the location of a bus stop into this method, the bus stop feature does not appear in the resulting array. On the other hand, if the style does include bus stops, an MLNFeature object representing that bus stop is returned and its featureAttributes dictionary has the maki key set to bus (along with other attributes). The dictionary contains only the attributes provided by the tile source; it does not include computed attribute values or rules about how the feature is rendered by the current style.

The returned array is sorted by z-order, starting with the topmost rendered feature and ending with the bottommost rendered feature. A feature that is rendered multiple times due to wrapping across the antimeridian at low zoom levels is included only once, subject to the caveat that follows.

Features come from tiled vector data or GeoJSON data that is converted to tiles internally, so feature geometries are clipped at tile boundaries and features may appear duplicated across tiles. For example, suppose the specified point lies along a road that spans the screen. The resulting array includes those parts of the road that lie within the map tile that contain the specified point, even if the road extends into other tiles.

To find out the layer names in a particular style, view the style in Maputnik.

Only visible features are returned. To obtain features regardless of visibility, use the MLNVectorTileSource/featuresInSourceLayersWithIdentifiers:predicate: and MLNShapeSource/featuresMatchingPredicate: methods on the relevant sources.

The returned features may also include features corresponding to annotations. These features are not object-equal to the MLNAnnotation objects that were originally added to the map. To query the map for annotations, use visibleAnnotations or MLNMapView/visibleAnnotationsInRect:.

@param point A point expressed in the map view’s coordinate system. @param styleLayerIdentifiers A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array. @param predicate A predicate to filter the returned features. @return An array of objects conforming to the MLNFeature protocol that represent features in the sources used by the current style.

Implementation

objc.NSArray visibleFeaturesAtPoint$2(objc.CGPoint point, {objc.NSSet? inStyleLayersWithIdentifiers,NSPredicate? predicate}) {
  final _ret = _objc_msgSend_19l1l5m(this.ref.pointer, _sel_visibleFeaturesAtPoint_inStyleLayersWithIdentifiers_predicate_, point, inStyleLayersWithIdentifiers?.ref.pointer ?? ffi.nullptr, predicate?.ref.pointer ?? ffi.nullptr);
  return objc.NSArray.castFromPointer(_ret, retain: true, release: true);
}