【发布时间】:2018-07-03 04:08:49
【问题描述】:
如何使用 swift 在 iOS 中通过点击谷歌地图来放置标记?代码如下:
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D)
{
let markerr = GMSMarker(position: coordinate)
markerr.position.latitude = coordinate.latitude
markerr.position.longitude = coordinate.longitude
print("hello")
print(markerr.position.latitude)
let ULlocation = markerr.position.latitude
let ULlgocation = markerr.position.longitude
print(ULlocation)
print(ULlgocation)
markerr.map = self.googleMapsView
mapView.delegate = self
}
【问题讨论】:
-
无需使用
mapView.delegate = self这一行以及您面临的问题 -
点按功能没有工作
-
你的意思是这个方法没有被称为
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D)正确否则 -
调用
You just have to initialize delegate atviewDidLoad`mapView.delegate = self
标签: ios swift google-maps google-maps-markers