Cant interact with custom infowindow in google map

不羁岁月 提交于 2019-12-07 11:59:32

A custom info window is rendered as an UIImage, so you cannot interact with anything on it. I had a similar problem, and ended up making the entire window one "button" that caused an embed segue to push a view over the map, giving me details (think Yelp app style).

My info window was contained in a separate .xib. Here is some code in my GMSMapViewDelegate:

func mapView(mapView: GMSMapView!, didTapInfoWindowOfMarker marker: GMSMarker!)
{
    ShowDetailView(mapMarkerManager!.GetMapMarker(marker)!)
}

func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView!
{
    let markerInfoWindow = UINib(nibName: "MarkerInfoPopup", bundle: nil).instantiateWithOwner(nil, options: nil)[0] as! MarkerInfoPopup

    markerInfoWindow.setValues(mapMarkerManager!.GetMapMarker(marker)!)
    return markerInfoWindow
}

private func ShowDetailView(mapMarker: MapMarker)
{
    delegate!.SetMapMarker(self, mapMarker: mapMarker)

    self.view.bringSubviewToFront(mapDetailView)
    mapDetailView.hidden = false

    mapView.hidden = true
    BackToMapButton.hidden = false
}

(mapMarker is more or less a GMSMarker wrapper. It does other stuff but is not important in this context)

I know this isn't exactly what you wanted, but unfortunately there aren't many options when using Google Maps' built in markerInfoWindow/didTapInfoWindowOfMarker.

Reference: https://developers.google.com/maps/documentation/ios-sdk/marker?hl=en#info_windows

"Note: The info window is rendered as an image each time it is displayed on the map. This means that any changes to its properties while it is active will not be immediately visible. The contents of the info window will be refreshed the next time that it is displayed."

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!