ch1maera
ch1maera

Reputation: 1447

Moving Google Maps Info Window in iOS

So I have a custom info window that appears whenever a user taps a pin in Google Maps. However, I want the info window to appear at the bottom of the screen when the user taps a pin and not above the pin as is default. Basically, when you tap the pin, the map centers on the pin as it does normally but I want the info window to appear at the very bottom of the screen, above the Google Maps logo. I'm currently using this function to show the custom info window:

func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> 
UIView? {
    let infoWindow = Bundle.main.loadNibNamed("customInfoWindow", owner: self, options: nil)?.first! as! customInfoWindow
    infoWindow.title.text = marker.title
    return infoWindow
}

Upvotes: 1

Views: 1273

Answers (1)

dRAGONAIR
dRAGONAIR

Reputation: 1191

According to the post above, i think you need to add a custom Label rather that the default info window. Implement the below delegate method.

func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
    // Add a Label on the Map at the desired position,
    // get the coordinates of the marker from 'marker.position'
    // use the coordinates for displaying it in the label or rev geo to get the address and display (according to the required spec.)
}

Upvotes: 3

Related Questions