'how to observe the iOS mapView didChangeVisibleRegion
hello Im working on an app that will show annotations over where the user is currently zoomed into, however I don't know how to use one of the functions because I am fairly new to mapkit.
func mapViewDidChangeVisibleRegion(_ mapView: MKMapView) {
if mapView.region.span.latitudeDelta = ?
}
Im using firebase and don't want to pull out every annotation that has ever been entered but only pull out annotations when a user is at a certain zoom and show those annotations. which is where I'm at a blank, the question mark is where I don't know what to enter. If anyone knows please help!? thank you!
Solution 1:[1]
I do not use swift, so I can't provide actual coding.... but the how the coding should work. This can all be performed in an HTTP request thread.
func mapViewDidChangeVisibleRegion(_ mapView: MKMapView) { /* App side */ // HTTP Method here pass the mapView.region.span.latitudeDelta and mapView.region.span.longitudeDelta
/* server side */
// Do math from the delta values passed
// Query the database based off the math
// Output data in json format
/* App side */
// Redraw the map annotations based of the json output
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | John Stevens |
