gpt4 book ai didi

ios - 适用于 iOS 的 Google map ,swift - 如何在标记之间显示整条多段线?

转载 作者:搜寻专家 更新时间:2023-10-30 22:22:18 27 4
gpt4 key购买 nike

我正在尝试在谷歌地图 View 中设置多段线。折线是通过 google maps directions api 中的 overview_polyline 获取的。

想知道如何将编码的多段线转换成可以使用的东西。我需要在 map View 中调整多段线。我发现要做的就是调整边界以显示所有标记,但不显示整条多段线。

func fitAllMarkers()
{

var bounds = GMSCoordinateBounds()

for marker in markers
{
bounds = bounds.includingCoordinate(marker.position)
}

googleMapView.animateWithCameraUpdate(GMSCameraUpdate.fitBounds(bounds))

}

最佳答案

对于 Swift 2.0 Google map ,要使您的 map View 适合您正在绘制的路线的多段线:

let path: GMSPath = GMSPath(fromEncodedPath: route)!
routePolyline = GMSPolyline(path: path)
routePolyline.map = mapView


var bounds = GMSCoordinateBounds()

for index in 1...path.count() {
bounds = bounds.includingCoordinate(path.coordinateAtIndex(index))
}

mapView.animateWithCameraUpdate(GMSCameraUpdate.fitBounds(bounds))

关于ios - 适用于 iOS 的 Google map ,swift - 如何在标记之间显示整条多段线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35095149/

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