我正在我的 iOS 应用程序中使用 Google map 。它将在两个坐标之间绘制线条,并在 map 上添加开始和结束位置作为“标记”。
我使用下面的代码添加开始和结束标记
//myLatLngArrayList is array of coordinates with latitude and longitude positions
markerA.position = (curDrill.myLatLngArrayList.first)! as CLLocationCoordinate2D
markerA.map = mapView
markerA.icon = UIImage(named: markerImages.0)
markerB.position = (curDrill.myLatLngArrayList.last)! as CLLocationCoordinate2D
markerB.map = mapView
markerB.icon = UIImage(named: markerImages.1)
我使用下面的代码来绘制线条:
let path = GMSMutablePath()
for coord in curDrill.myLatLngArrayList {
path.add(coord)
}
let drillPath = GMSPolyline.init(path: path)
drillPath.strokeWidth = 2.0
drillPath.strokeColor = UIColor(Utility.getDrillColor(type: curDrill.type))
drillPath.map = mapView
问题是标记位置与线的起点和终点不匹配。标记 A 未接触行首,标记 B 未接触行尾。
我无法确定我的代码中缺少什么。
最佳答案
尝试添加您从 google API 收到的从第一个点到最后一个点的所有步数坐标。
关于ios - 在 GSMapView 中添加标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44587345/