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:
So i have made an xib file with a class to make the custom window which looks like that:
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:
This problem has been annoying me for so much time, so how can I fix it??