Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GMSMapView - how to get callback when map did end moving from scrolling

I need to get a callback from GMSMapView when it stopped moving.

I have read the documentation and i have found "mapView:idleAtCameraPosition:" method, but it's not quite what i'm looking for. This method gets called too often, not just when the mapView did end moving.

Any idea?

like image 227
Vlad Bogdan Avatar asked Dec 17 '13 23:12

Vlad Bogdan


1 Answers

Add a boolean to track whether the map has started being dragged. Then on mapView:willMove: set it to true. In idleAtCameraPosition, only update if this variable is true:

func mapView(mapView: GMSMapView!, idleAtCameraPosition position: GMSCameraPosition!) {
    if locationDragged == true {
        locationDragged = false
        println("changed position: \(mapView.camera.target)")
        // do stuff
    }
}
like image 74
mitrenegade Avatar answered Nov 06 '22 05:11

mitrenegade