Close info window of a marker programmatically google maps iOS
Asked Answered
A

2

15

I know it's easy in the java version of Google Maps but I can't figure out how to get the info window to close in the objective C version of the SDK.

I'm using this method:

-(void) mapView:(GMSMapView *)mapView
    didTapInfoWindowOfMarker:(id<GMSMarker>)marker {

    sharedGlobal.shouldShowPlayer = YES;

    /* adds the path to the map by decoding google's encoded string */
    [self addPath: sharedGlobal.encodedPathString];
}

And want to add a line to close the infowindow associated with marker.

Antiquated answered 3/4, 2013 at 18:9 Comment(0)
M
39

I think you can use this:

mapView.selectedMarker = nil;

The comments on the selectedMarker property in GMSMapView.h say this:

/**
 * The marker that is selected.  Setting this property selects a particular
 * marker, showing an info window on it.  If this property is non-nil, setting
 * it to nil deselects the marker, hiding the info window.  This property is
 * observable using KVO.
 */
@property (nonatomic, strong) id<GMSMarker> selectedMarker;
Meshed answered 4/4, 2013 at 1:3 Comment(1)
very well answered...Thank youConcettaconcettina
M
0

SWIFT

mapView.selectedMarker?.title = nil
Myotonia answered 31/5, 2018 at 14:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.