gpt4 book ai didi

ios - 当我点击标记时,Google map 的旧行为

转载 作者:行者123 更新时间:2023-11-30 11:58:00 25 4
gpt4 key购买 nike

我使用的是 xcode 9.0、GoogleMaps SDK 2.5.0 和 GooglePlaces 2.5.0。

在方法中 func mapView(_ mapView: GMSMapView, didTap mark: GMSMarker) -> Bool 当我选择一个标记并返回到仅显示标记且不启用自动居中的旧行为。问题是,当我实现该行为(注释的行)时,标记不会出现,我搜索的所有堆栈溢出都实现了这些行。我迷路了

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
}
}

最佳答案

如果有人遇到这个奇怪的错误,奇怪的解决方案是再次添加委托(delegate):

func mapView(_ mapView: GMSMapView, didTap marker: GMSMarker) -> Bool {
mapView.delegate = self
mapView.selectedMarker = marker
return true

return false
}

关于ios - 当我点击标记时,Google map 的旧行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47578039/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com