Anh Bui
Anh Bui

Reputation: 285

Mapbox iOS - Cannot find the function similar to "visibleFeatures" on version 10

I'm working on task migration Mapbox from version 3.6 to version 10.0 Now I'm facing the issue that in the old version, I use "visibleFeatures" function to get MGLFeature when user tap on the map.

@objc func handleTapWithGestureRecognizer(_ tapGestureRecognizer: UITapGestureRecognizer) {
let point = tapGestureRecognizer.location(in: mapBoxView)
let target = mapBoxView.visibleFeatures(at: point, styleLayerIdentifiers: ["layer01", "layer02"], predicate: NSPredicate(format: "%K != '' AND offset >= 0 ","local_path"))
...

}

But at version 10.0, I could not find any function similar to "visibleFeatures". Anyone please help

Thank you all!

Upvotes: 0

Views: 461

Answers (1)

swiftyboi
swiftyboi

Reputation: 3221

Try this:

// Query rendered features at point
mapView.mapboxMap.queryRenderedFeatures(at: point, options: nil, completion: { [weak self] result in
      switch result {
      case .success(let features):
            // Do something with the features
      case .failure(let error):
            print(error.localizedDescription)
      }
})

Upvotes: 1

Related Questions