3

I've been using the method posted below to display a custom info window, but whenever I run it, only the default window (with the title/snippet) shows up? I have created both an xib and swift file for the following method, and I was trying to implement it using standard function notation (i.e. mapView(mapView, markerInfoWindow:mapView.currentMarker), but that wasn't compiling (tried with and without the explicit implementation). Any ideas?

Thanks,

Jacob

func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {
        var infoWindow = NSBundle.mainBundle().loadNibNamed("InfoWindow", owner: self, options: nil).first! as InfoWindow
        infoWindow.label.text = "\(marker.position.latitude) \(marker.position.longitude)"
        return infoWindow
 }

Contents of InfoWindow:

class InfoWindow: UIView {

    @IBOutlet var label: UILabel!
    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func drawRect(rect: CGRect) {
    // Drawing code
    }
    */

}
Jacob Platin
  • 319
  • 3
  • 11
  • 3
    It is probably that you didnt set your `mapView`'s delegate, you can set it by doing `mapView.delegate = self` in your `viewDidLoad()` method. – ztan Aug 31 '15 at 17:15

0 Answers0