Search code examples
iosmapkitswift5.9

Get continuous movement reports from MapKit, rather than only at the end of a move?


As it says, regionDidChangeAnimated is only called when a user has finished fingering zooming/moving.

(And indeed only after any bounce or settle finishes.)

func mapView(_ mapView: MKMapView, regionDidChangeAnimated animated: Bool) {
    .. user has >finished< a finger event
    .. example ..
    let k = mapView.annotations(in: mapView.visibleMapRect).count
    print("now on screen", k)
}

Is there a way to get continuous reports, so as to for example change something in your interface as the user zooms/moves


Solution

  • The mapViewDidChangeVisibleRegion(_:) provides continuous reports as the user pans/zooms the map.

    func mapViewDidChangeVisibleRegion(_ mapView: MKMapView) {
        …
    }