Google Maps for iOS, swift - How to show entire polyline between markers?

后端 未结 4 697
Happy的楠姐
Happy的楠姐 2021-01-12 13:19

I am trying to fit a polyline in the google map view. The polyline was acquired through overview_polyline in the google maps directions api.

Wondering how I would b

4条回答
  •  忘掉有多难
    2021-01-12 13:52

    **For Swift 3.0 Google Maps, to make your map view fit the polyline of the route you are drawing:** 
    
    
    func fitAllMarkers(_path: GMSPath) {
            var bounds = GMSCoordinateBounds()
            for index in 1..._path.count() {
                bounds = bounds.includingCoordinate(_path.coordinate(at: index))
            }
            mapView.animate(with: GMSCameraUpdate.fit(bounds))
        }
    

提交回复
热议问题