How to show a Info window in iOS Google maps without tapping on Marker?

albeee picture albeee · Apr 4, 2013 · Viewed 41.6k times · Source

I am new to iOS development. This is regarding Marker info window in Google Maps iOS SDK.

I understand, we can create a marker with info window using GMSMarkerOption.

GMSMarkerOption *myLocationOption = [GMSMarkerOption alloc];
myLocationOption .title = @"My Location";
myLocationOption .snippet = @"Lat:...., Lang:....";

[mapView addMarkerOption:myLocationOption];

As per the above code, Marker displayed in the Map View as expected. And tapping on marker shows the "My Location" info window in Google maps which is good.

Is there anyway we can show the info window programmatically when the user goes to Custom Map Screen?

Answer

estemendoza picture estemendoza · Oct 10, 2013

This has changed on Google Maps SDK and it's easier to understand:

GMSMarker *marker = [[GMSMarker alloc] init];
marker.position = coordinate;
marker.title = @"Location selected";
marker.snippet = @"Testing";
marker.map = mapView_;

//Show info window on map
[mapView_ setSelectedMarker:marker];

You use now setSelectedMarker method to show an info window of a marker