Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Close info window of a marker programmatically google maps iOS

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.

like image 297
CSStudent Avatar asked Apr 03 '13 18:04

CSStudent


People also ask

How do I put InfoWindow on marker?

Move an info windowAttach the info window to a new marker using the InfoWindow. open() method. Note: If you call open() without passing a marker, the InfoWindow will use the position specified upon construction through the InfoWindowOptions object literal.

How do I get rid of InfoWindow in Google Maps?

The user can click the close button on the InfoWindow to remove it from the map, or the developer can call close() for the same effect.

How do I remove a marker from Google Maps IOS?

You can remove a marker from the map by setting the map property of the GMSMarker to nil . Alternatively, you can remove all of the overlays (including markers) currently on the map by calling the GMSMapView clear method.


1 Answers

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;
like image 138
Saxon Druce Avatar answered Oct 27 '22 00:10

Saxon Druce