P.T*_*.Tb 3 google-maps google-maps-markers ios swift
我想Marker在Google地图中添加和删除(固定)。
我想长时间触摸掉别针并将其删除。我想用它来选择我的目的地。我该怎么做?
let position = CLLocationCoordinate2DMake(10, 10)
let marker = GMSMarker(position: position)
marker.map = mapView
Run Code Online (Sandbox Code Playgroud)
对于那些正在寻找使用Swift的完整代码段的人:
GMSMapViewDelegate@IBOutlet weak var googleMapView: GMSMapView!viewDidLoad()为googleMapView.delegate = selfdidTapAt委托功能:func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D){
print("You tapped at \(coordinate.latitude), \(coordinate.longitude)")
googleMapView.clear() // clearing Pin before adding new
let marker = GMSMarker(position: coordinate)
marker.map = googleMapView
}
| 归档时间: |
|
| 查看次数: |
2293 次 |
| 最近记录: |