如何使用 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
}
最佳答案
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D) {
mapView.clear()
DispatchQueue.main.async {
let position = CLLocationCoordinate2D(latitude: coordinate.latitude, longitude: coordinate.longitude)
self.marker.position = position
self.marker.map = mapView
self.marker.icon = UIImage(named: "default_marker")
print("New Marker Lat Long - ",coordinate.latitude, coordinate.longitude)
}
}
关于ios - 如何使用 swift 在 iOS 中点击谷歌地图来放置标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48416965/