Swift 3:如何在Google地图中删除跟踪的折线 [英] Swift 3: How to remove the tracked polyline in Google map
本文介绍了Swift 3:如何在Google地图中删除跟踪的折线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经画出了折线,但是我并不是没有什么编码可以删除Google地图中的追踪折线. 我在下面尝试一些编码.
I have draw the polylines, but I don't no that what coding can remove the tracked polyline in the google map. I'm trying some coding in below.
这是行不通的.
var polyline = GMSPolyline()
polyline.map = nil
这可以删除跟踪的折线,但是当我创建了标记并点按它时,标记无法播种信息窗口.
this is working to remove tracked polyline, but when I'm maked the markers and tap it, marker can not sow the info window.
mapView.clear()
谢谢
推荐答案
解决方案:
- 创建折线:通过GoogleMapsAPIs教学折线
- 创建变量oldPolylineArr/oldPolyline类型GMSPolyline/GMSPolyline_Array
- 将折线存储到oldPolyline
- 删除折线
- create polyline: teaching polyline by GoogleMapsAPIs
- create variable oldPolylineArr/oldPolyline type GMSPolyline/GMSPolyline_Array
- store the polyline to the oldPolyline
- remove the polyline
样本编码:
//Step 1:
var mapView = GMSMapView()
let path = GMSMutablePath()
path.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.0))
path.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.0))
path.add(CLLocationCoordinate2D(latitude: 37.45, longitude: -122.2))
path.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.2))
path.add(CLLocationCoordinate2D(latitude: 37.36, longitude: -122.0))
let rectangle = GMSPolyline(path: path)
//Step 2:
var oldPolylineArr = [GMSPolyline]()
数组
//Step 3:
oldPolyline.append(rectangle)
//Step 4:
for p in (0 ..< oldPolylineArr.count) {
oldPolylineArr[p].map = nil
}
不是数组
//Step 3:
oldPolyline = polyline
//Step 4:
oldPolyline.map = nil
这篇关于Swift 3:如何在Google地图中删除跟踪的折线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文