我怎样才能用单个标记多次敲击
how can I multiple tapping with single marker
通过点击,它使标记无限大。我想要一个我点击的标记。一遍又一遍地。没有很多标记。
我使用了 MapView.clean()。但它会删除所有标记。
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D)
{
let marker = GMSMarker(position: coordinate)
marker.position.latitude = coordinate.latitude
marker.position.longitude = coordinate.longitude
print("hello")
print(markerr.position.latitude)
let ULlocation = markerr.position.latitude
let ULlgocation = markerr.position.longitude
print(ULlocation)
print(ULlgocation)
marker.map = self.mapView
}
在 didTapAt coordinate
方法之外创建标记并在此方法中更改其坐标
class ViewController: UIViewController, GMSMapViewDelegate {
let marker = GMSMarker()
override func viewDidLoad() {
super.viewDidLoad()
marker.map = self.mapView
}
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D)
{
marker.position = coordinate
}
}
通过点击,它使标记无限大。我想要一个我点击的标记。一遍又一遍地。没有很多标记。
我使用了 MapView.clean()。但它会删除所有标记。
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D)
{
let marker = GMSMarker(position: coordinate)
marker.position.latitude = coordinate.latitude
marker.position.longitude = coordinate.longitude
print("hello")
print(markerr.position.latitude)
let ULlocation = markerr.position.latitude
let ULlgocation = markerr.position.longitude
print(ULlocation)
print(ULlgocation)
marker.map = self.mapView
}
在 didTapAt coordinate
方法之外创建标记并在此方法中更改其坐标
class ViewController: UIViewController, GMSMapViewDelegate {
let marker = GMSMarker()
override func viewDidLoad() {
super.viewDidLoad()
marker.map = self.mapView
}
func mapView(_ mapView: GMSMapView, didTapAt coordinate: CLLocationCoordinate2D)
{
marker.position = coordinate
}
}