Я не понимаю, как изменить положение моих окон в соответствии с положением маркера.Когда я изменил значение x или y, ничего не произошло.
Вот мой код:
func mapView(_ mapView: GMSMapView, markerInfoWindow marker: GMSMarker) -> UIView? {
let sarahBlue = UIColor(red: 33, green: 48, blue: 78, a: 1)
let view = UIView(frame: CGRect.init(x: 0, y: 0, width: 200, height: 70))
view.backgroundColor = sarahBlue
view.layer.cornerRadius = 6
if let pointName = marker.title {
let imgVw : UIImageView = {
let iv = UIImageView()
iv.image = UIImage(named: "La maison des tramwayen1")
iv.translatesAutoresizingMaskIntoConstraints = false
return iv
}()
let lbl : UILabel = {
let lbl = UILabel()
let yellowSarah = UIColor(red: 242, green: 191, blue: 5, a: 1)
lbl.textColor = yellowSarah
lbl.font = UIFont(name: "Arial Rounded MT Bold", size: 10)
lbl.textAlignment = NSTextAlignment.center
lbl.numberOfLines = 0
lbl.sizeToFit()
lbl.text = marker.title
lbl.translatesAutoresizingMaskIntoConstraints = false
return lbl
}()
var pointNameWithoutAcc : String = pointName.replacingOccurrences(of: "é", with: "e")
pointNameWithoutAcc = pointNameWithoutAcc.replacingOccurrences(of: "è", with: "e")
view.addSubview(imgVw)
imgVw.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 5).isActive = true
imgVw.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -5).isActive = true
imgVw.topAnchor.constraint(equalTo: view.topAnchor, constant: 5).isActive = true
imgVw.widthAnchor.constraint(equalTo: view.heightAnchor, multiplier: 1).isActive = true
let imageName = pointNameWithoutAcc + "0" + "SL"
imgVw.image = UIImage(named: imageName)
view.addSubview(lbl)
lbl.leftAnchor.constraint(equalTo: imgVw.rightAnchor, constant: 5).isActive = true
lbl.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 0).isActive = true
lbl.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20).isActive = true
}
return view
}
Мой код выполняется, когда я нажимаю на маркер, и пользовательские окна добавляются вверхмаркер.