I am starting to use the MapBox iOS SDK.
Is there any possible way to query the MapView by a coordinate and get back the terrain-type (water, land) as a result?
I've been reading the API doc for quite a while now, but could not figure it out. I know that there are (interim) solutions available to use a Google webservice, but I need this to work offline.
I am not bound to MapBox (but I like it) though, thank you for any hint!
No need to delve into runtime styling (see my other answer, false lead): very simple method using mapView.visibleFeatures(at: CGPoint, styleLayerIdentifiers: Set<String>) equivalent for javascript API is queryRenderedFeatures.
func mapView(_ mapView: MGLMapView, regionDidChangeAnimated animated: Bool)
{
let features = mapView.visibleFeatures(at: mapView.center, styleLayerIdentifiers: ["water"])
print(features)
}
Example output when moving around:
[]
[]
[]
[<MGLMultiPolygonFeature: 0x170284650>]
If empty result: no water, if polygon: water.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With