Trigger when the "myLocation" button is pressed (Google Maps SDK for iOS)

I want to do something when the "myLocation" button is clicked. So far I myself UIButton:

UIButton *btnMyLoc = (UIButton*)[self.googleMapView subviews].lastObject;

But this is not enough. Any ideas?

+4
source share
3 answers

There is currently no direct method on Google Maps iOS sdk to find out when a user clicks the MyLocation button . A possible workaround is to use the method below

- (void) mapView: (GMSMapView *) mapView  idleAtCameraPosition: (GMSCameraPosition *)   position 

. mylocation, , , ( ) . , idleAtCameraPosition, , , - (CLLocation*) myLocation [read, assign], .

+1

1.9.2 , :

(BOOL) didTapMyLocationButtonForMapView: (GMSMapView *) mapView [optional]

+14

.

// custom target My Location Button
    for (UIView* tmpview in _mapView.subviews[1].subviews[0].subviews) {
        if ([NSStringFromClass([[tmpview class] class]) isEqualToString:@"GMSx_QTMButton"]) {
            if ([tmpview isKindOfClass:[UIButton class]]) {
                myLocationBtn = (UIButton*)tmpview;
                [myLocationBtn addTarget:self action:@selector(clickedOnLocationButton:) forControlEvents:UIControlEventTouchUpInside];
            }
        }
    }
0

All Articles