从Google Map Swift 4删除标记

时间:2018-10-05 05:37:18

标签: ios google-maps swift4 google-maps-sdk-ios

我正在开发一个iOS应用,我需要在地图上向用户显示一些位置。为此,我正在使用谷歌地图。而且真的很好用

信息:在我的应用中,我将视图控制器分为两半。上面的区域显示地图,下面的区域显示UITableView,其中包含从数据库填充的位置。

我到目前为止所做的事情:现在,我从数据库中保存的位置填充列表和google地图。假设我有30个不同的位置,并且通过在地图上放置每个标记并将该标记添加到UItable中来显示地图上的所有位置。每个单元格都包含位置名称和用于从数据库中删除位置的删除按钮

我想要的:

  

现在我要的是用户可以点击单元格中的删除按钮   删除标记。我真的想从地图上删除该标记   也是实时的。但是我不知道该怎么做。请帮助

1 个答案:

答案 0 :(得分:0)

检查下面的代码

[Pipeline] { (SCM Checkout of Reporting Service)
[Pipeline] checkout
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url ssh://git@adlm.org.com:7999/~raja8008/ad-service.git # timeout=10
Cleaning workspace
 > git rev-parse --verify HEAD # timeout=10
Resetting working tree
 > git reset --hard # timeout=10
 > git clean -fdx # timeout=10
Fetching upstream changes from ssh://git@adlm.org.com:7999/~raja8008/ad-service.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress ssh://git@adlm.org.com:7999/~raja8008/ad-service.git +refs/heads/*:refs/remotes/origin/*
 > git rev-parse refs/remotes/origin/develop^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/develop^{commit} # timeout=10
Checking out Revision d25889e0eb6c52bfe4dd6a5c76e9bdaadd941924 (refs/remotes/origin/develop)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f d25889e0eb6c52bfe4dd6a5c76e9bdaadd941924
Commit message: "Merge pull request #3 in ADDD/ad-service from ~RAJA8008/ad-service:develop to develop"
 > git rev-list --no-walk d25889e0eb6c52bfe4dd6a5c76e9bdaadd941924 # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build Reporting Service)
[Pipeline] dir
Running in /temp/workspace/testadexp/ad-service
[Pipeline] {
[Pipeline] sh
[ad-service] Running shell script
+ ls -lah
total 8.0K
drwxr-xr-x.  2 1009100 25198 4.0K Oct  5 05:18 .
drwxr-xr-x. 10 1009100 25198 4.0K Oct  5 05:18 ..
[Pipeline] sh
[ad-service] Running shell script
+ mvn clean install
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.107 s
[INFO] Finished at: 2018-10-05T05:18:29Z
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/temp/workspace/testadexp/ad-service). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 

其中

func removeMarkers(mapView: GMSMapView){
    for (index, _) in markers.enumerate() {
        //print("Item \(index): \(element)")
                    self.markers[index].map = nil
    }
}

标记包含mapView的所有标记叠加层

OR

var标记= GMSMarker 标记包含mapView的所有标记叠加层

点击删除

var markers = [GMSMarker]()