gpt4 book ai didi

ios - Swift 3 在运行过程中使用 Google map 绘制折线

转载 作者:行者123 更新时间:2023-11-30 12:48:09 25 4
gpt4 key购买 nike

我找到了以下用于在运行/步行期间使用 Apple map 绘制路径的方法

extension NewRunViewController: MKMapViewDelegate {
func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! {
if !overlay.isKindOfClass(MKPolyline) {
return nil
}

let polyline = overlay as! MKPolyline
let renderer = MKPolylineRenderer(polyline: polyline)
renderer.strokeColor = UIColor.blueColor()
renderer.lineWidth = 3
return renderer
}
}

但是我尝试使用 Google map 执行此操作,但找不到解决方案。很多很多答案都适用于 Apple map ,但 Google map 上的答案并不多。

最佳答案

试试这个

let path = GMSMutablePath()
//Change coordinates
path.add(CLLocationCoordinate2D(latitude: -33.85, longitude: 151.20))
path.add(CLLocationCoordinate2D(latitude: -33.70, longitude: 151.40))
path.add(CLLocationCoordinate2D(latitude: -33.73, longitude: 151.41))
let polyline = GMSPolyline(path: path)
polyline.strokeColor = UIColor.blue
polyline.strokeWidth = 3.0
polyline.map = mapView

关于ios - Swift 3 在运行过程中使用 Google map 绘制折线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41354890/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com