RPatel99
RPatel99

Reputation: 8116

Programmatically display a GMSMarker's info window

I know there is already a question similar to this on SO (Displaying info window when tapped marker in google maps iOS sdk while implementing mapView:didTapMarker: delegate method implemented) but the answer does not apply in my case.

In my mapView(didTap:) delegate method, it has to return true because I programmatically determine the camera position when a marker is tapped. If I return true like the answer in the above question says, the map is automatically centered on the selected marker, which I do not want. Since I return true, tapping a marker does not display the marker's information window, which I still want to occur, so is there a way for me to do that programmatically?

I don't think the code in my mapView(didTap:) delegate method is necessary for answering this question, but if anyone needs it, let me know. (Keep in mind that my question question refers to the delegate method for when a marker is tapped, not the delegate method for when an info window is tapped, mapView(didTapInfoWindowOf:))

Thanks in advance.

Edit:

Looking through the Google Maps Documentation, I found out that there is a method for what I am looking for in JavaScript called showInfoWindow() that you call on the marker who's info window you want to show (this is the link to the documentation I'm talking about). So does anyone know a Swift 3 alternative to this method?

Edit:

If I return false in the delegate method, the camera instantly moves to the marker's location for a split second, and then pans over to the location I programmatically tell it to move to. This technically works, but it is ugly and not fluent, so I still need a way to programmatically show the marker's information window while the delegate method returns true.

Upvotes: 0

Views: 1490

Answers (1)

RPatel99
RPatel99

Reputation: 8116

After going on google's issue tracker and submitting a post, I found out that mapView.selectedMarker() = marker does not actually have any connection to the mapView(didTap:) delegate method, so returning true in the delegate method has no impact on the selectedMarker() method's functionality.

As a result I can just add mapView.selectedMarker() = marker in the delegate method after customizing the location I want to animate the mapView to and before returning true, which causes the marker's info window to pop up without messing with the camera position.

Upvotes: 1

Related Questions