I have a google map which contains multiple buttons as markers, I set marker position & title using:
self.mapView.delegate = self
let camera = GMSCameraPosition.camera(withLatitude: -7.0343237999999992, longitude: 110.42400399999997, zoom: 15)
self.mapView.animate(to: camera)
let infoWindow = Bundle.main.loadNibNamed("MapsWindows", owner: self, options: nil)?.first! as! MapsWindows
let markerView = infoWindow
for state in self.states {
let marker = GMSMarker()
marker.position = CLLocationCoordinate2DMake(state.lat, state.long)
infoWindow.titleButton.setTitle(state.name, for: .normal)
marker.iconView = markerView
marker.map = self.mapView
}
the position is correct, but button's title always set to latest index of array. So all of my buttons have the same title. How to make the button title appropriate order?