1

I am using GoogleMaps SDK in my iOS application. I have implemented custom info window for GoogleMaps and calling it my ViewController as,

func mapView(mapView: GMSMapView!, markerInfoContents marker: GMSMarker!) -> UIView! {
    var calloutView:CalloutView = NSBundle.mainBundle().loadNibNamed("CalloutView", owner: self, options: nil)[0] as! CalloutView
    views!.detailDisclosure.addTarget(self, action: "detailDisclosureButton_Clicked:", forControlEvents: UIControlEvents.TouchUpInside)
    views.labelText.text = "ABC Text"
 return views

}

And getting output as below enter image description here

Info window overlapping and showing bottom edges as below. Also button on info window not getting clicked. Please help for the same.

TechSavy
  • 797
  • 2
  • 8
  • 22

1 Answers1

2

With my experience, - mapView:markerInfoContents: have some problems. In my case, I ended up using - mapView:markerInfoWindow: instead. In this case, you have to draw balloon image by yourself, like this:

ballon images

Also button on info window not getting clicked.

As documented on the bottom of this, markerInfoWindow is rendered as an image, but not true UIView.

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.

It does not receive any UI events. So, sad to say, any UIControls on markerInfoWindow is useless. The only supported way is to use - mapView:didTapInfoWindowOfMarker: delegate method, that means, you can not define multiple clickable areas on the info window.

rintaro
  • 51,423
  • 14
  • 131
  • 139
  • Thanks a lot it works. But the info window overlapping the marker view. How to resolve it? – TechSavy Jul 13 '15 at 11:43
  • You can adjust the position of the info window with [`infoWindowAnchor`](https://developers.google.com/maps/documentation/ios/reference/interface_g_m_s_marker.html#a6668957ca7b6857355ee6cd9ab944a92) property of `GMSMarker`. see: https://developers.google.com/maps/documentation/ios/marker#customize_a_marker – rintaro Jul 13 '15 at 11:53