I want to do some stuff when 'myLocation' button tapped.
So far, I've the UIButton
itself:
UIButton *btnMyLoc = (UIButton*)[self.googleMapView subviews].lastObject;
But it's not enough. Any ideas?
In release 1.9.2 there is a delegate method that does exactly that:
(BOOL) didTapMyLocationButtonForMapView: (GMSMapView *) mapView [optional]
Link to documentation
Delegate method available
func didTapMyLocationButton(for mapView: GMSMapView) -> Bool{
}
Currently there is no direct method in Google Maps IOS sdk for knowing when the user taps on MyLocation button. A possible workaround is to use the below method
- (void) mapView: (GMSMapView *) mapView idleAtCameraPosition: (GMSCameraPosition *) position
This will be called at the end of any camera animation or gestures. When a user clicks mylocation button, the camera will be animated to position the visible map region such that the user's current location(if detected) will lie at the center. So you can check inside idleAtCameraPosition whether the location is same as the user's current location that can be known through - (CLLocation*) myLocation [read, assign]
and do your required functionality.
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