所以我在swiftui中实现了谷歌地图sdk,由于某种原因,委托函数mapView(_:didTapPOIWithPlaceID:name:location:)没有被调用,但函数func mapView(_ mapView: GMSMapView, didTapAt坐标: CLLocationCooperative2D) 是。我正在点击 pois。所以我现在真的不知道我做错了什么。
override func viewDidLoad() {
super.viewDidLoad()
let options = GMSMapViewOptions()
options.frame = self.view.bounds;
let mapView = GMSMapView(options:options)
mapView.settings.myLocationButton = true
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
mapView.isMyLocationEnabled = true
mapView.delegate = self
self.view.addSubview(mapView)
self.mapView = mapView
}
func mapView(_ mapView: GMSMapView, didTapPOIWithPlaceID placeID: String, name: String, location: CLLocationCoordinate2D) {
// Not being called
infoMarker.snippet = placeID
infoMarker.position = location
infoMarker.title = name
infoMarker.opacity = 0;
infoMarker.infoWindowAnchor.y = 1
infoMarker.map = mapView
mapView.selectedMarker = infoMarker
}
首先,抱歉我无法发表评论,因为我没有足够的声誉,所以我必须这样回答。
我在使用 Maps SDK 9.0.0 时遇到了同样的问题,并恢复到 8.4.0 解决了该问题。这似乎是谷歌端的一个错误。我也许应该给他们写一张罚单