0

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!

Anh Bui
  • 287
  • 1
  • 2
  • 9

1 Answers1

1

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)
      }
})
swiftyboi
  • 2,965
  • 4
  • 25
  • 52