I'm using xcode 9.0, GoogleMaps SDK 2.5.0 and GooglePlaces 2.5.0.
In the method func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool
I'm trying to disable the auto center map, when I select a marker and go back to the old behaviour of only showing the marker and no auto center enabled. The problem is that the marker doesn't appear when I implement that behaviour (lines that are commented), all stack overflow I searched implements those lines. I'm lost
class MapViewController: UIViewController, GMSMapViewDelegate
{
//MARK: Class Life Cycle
@IBOutlet weak var mapView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
setupUI()
setupMap()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
//MARK: -Setup
func setupUI() {
navigationController?.hideBar()
}
func setupMap() {
let map = MapManager.sharedInstance.setupMap(view: mapView, latitude: GoogleMap.latitude, longitude: GoogleMap.longitude, zoom: GoogleMap.zoom)
map.delegate = self
mapView.addSubview(map)
MapManager.sharedInstance.setupMapMarkers(map: map, file: File.geoFence, fileType: File.json)
}
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
// mapView.selectedMarker = marker
// return true
return false
}
}
If anyone comes across this odd bug, the odd solution is adding the delegate again:
func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
mapView.delegate = self
mapView.selectedMarker = marker
return true
return false
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.