简体   繁体   English

如何使用单个标记多次点击

[英]how can I multiple tapping with single marker

by tapping, it makes marker infinity. 通过点击,它使标记无限。 i want to one marker where I tapped. 我想要一个标记,我点击了。 over and over again. 一遍又一遍地。 not with lots markers. 没有很多标记。

在此处输入图片说明

I used MapView.clean(). 我使用了MapView.clean()。 but it delete every markers. 但会删除所有标记。

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
}

Create the marker outside the didTapAt coordinate method and change it's coordinates in this method 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
    }
}

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过点击图像以编程方式进行搜索? - How can I programmatically segue with tapping on an Image? 如何在iOS中快速显示多个标记的标记标题而不用点击它,就像iOS中照片库中的位置一样 - how to display marker title for multiple markers without tapping on it in iOS swift like places in photo gallery in iOS 如何通过用户点击或在其他地方轻扫来删除UIView? - How can I remove a UIView by the user tapping or swiping anywhere else? 使用XCTest点击UI元素时,如何避免NSInternalInconsistencyException? - How can I avoid NSInternalInconsistencyException when tapping on UI elements with XCTest? 如何通过单击带有黄色圆圈的按钮来隐藏键盘? - How can i hide keyboard by tapping into the button with yellow circle? 如何在不点击的情况下在导航栏中突出显示BarButton? - How can I highlight the BarButton in navigation bar without tapping it? 点击Google地图中的标记时如何防止相机移动? - How to prevent camera from moving when tapping marker in Google Maps? 如何在不点击标记的情况下在 iOS 谷歌地图中显示信息窗口? - How to show a Info window in iOS Google maps without tapping on Marker? 如何为单个图像提供多个选择选项? - How can i have multiple select options for a single image? 如何在单个循环中添加多个textField? - How I can add multiple textField in a single Loop?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM