0

I am trying to add a map in my app that shows dome locations and a description of each location in a custom info window which is supposed to look like that:

enter image description here

So i have made an xib file with a class to make the custom window which looks like that:

enter image description here

And its class:

import UIKit

class CustomInfoWindow: UIViewController {

    @IBOutlet weak var name = UILabel()
    @IBOutlet weak var desc = UITextView()

    override func viewDidLoad() {
        super.viewDidLoad()

    }

    init(name:String, desc:String) {
        self.name?.text = name
        self.desc?.text = desc
        super.init(nibName: nil, bundle: nil)
    }

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

Now whenever I implement the map's delegate method that returns a UIView for the marker info window and add the text as in here:

func mapView(_ mapView: GMSMapView, markerInfoContents marker: GMSMarker) -> UIView? {
    if marker.position.latitude == latitude && marker.position.longitude == longitude{
        marker.title = "You"
        return nil
    }else{
    let customWindow = CustomInfoWindow(name: theName!, desc: theDesc!)
    return customWindow.view

    }
}

That is what I get:

enter image description here

This problem has been annoying me for so much time, so how can I fix it??

MrUpsidown
  • 21,592
  • 15
  • 77
  • 131
user3407319
  • 227
  • 2
  • 10

0 Answers0