【问题标题】:how can I multiple tapping with single marker如何用单个标记多次点击
【发布时间】:2019-05-09 02:23:38
【问题描述】:

通过点击,它使标记无限。我想要一个我点击的标记。一遍又一遍地。没有很多标记。

我使用了 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
}

【问题讨论】:

    标签: ios swift dictionary sdk marker


    【解决方案1】:

    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
        }
    }
    

    【讨论】:

    • @smoo.an 在 didTapAt 坐标法中?
    • 顶部。让标记= GMSMarker(位置:坐标)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-03
    • 2017-04-06
    • 1970-01-01
    • 1970-01-01
    • 2017-09-10
    • 1970-01-01
    • 2021-05-05
    相关资源
    最近更新 更多