Search code examples
iosgoogle-mapsinfowindowgoogle-maps-sdk-ios

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


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?


Solution

  • GMSMarkerOptions *myLocationOptions = [GMSMarkerOptions options];
    myLocationOptions.title = @"My Location";
    myLocationOptions.snippet = @"Lat:...., Lang:....";
    
    mapView.selectedMarker = [mapView addMarkerWithOptions:myLocationOptions];
    

    (note that it's Options, not Option)