Skip to content

Instantly share code, notes, and snippets.

@ryanisnhp
Created May 31, 2020 11:22
Show Gist options
  • Save ryanisnhp/f76eaab43a559632da131100aa82a8bd to your computer and use it in GitHub Desktop.
Save ryanisnhp/f76eaab43a559632da131100aa82a8bd to your computer and use it in GitHub Desktop.
//STEP 2: - DRAW A ROUTE ON THE MAP
func drawRouteOnMap(route: String?) {
guard let route = route else {return}
guard let path = GMSPath(fromEncodedPath: route) else {return}
self.path = path
let polyline = GMSPolyline(path: path)
polyline.strokeColor = .gray
polyline.strokeWidth = 2
polyline.map = mapView
// (Optional) Add bounds and insets to let the route is at the center of the map
let bounds = GMSCoordinateBounds(path: path)
let insets = UIEdgeInsets(top: 20, left: 40, bottom: 20, right: 40)
let camera = GMSCameraUpdate.fit(bounds, with: insets)
mapView.animate(with: camera)
//STEP 3: - ANIMATIONS
startAnimationTimer()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment