As you know get directions and routes from google is NOT FREE and last year google changed their api calls prices a lot! So it may not suitable for everyone. So if you have all key coordinates and just want to connect them together, you can use the following.
- Swift 4 Extensions
Make path with coordinates:
extension GMSMutablePath {
convenience init(coordinates: [CLLocationCoordinate2D]) {
self.init()
for coordinate in coordinates {
add(coordinate)
}
}
}
Add path to map:
extension GMSMapView {
func addPath(_ path: GMSPath, strokeColor: UIColor? = nil, strokeWidth: CGFloat? = nil, geodesic: Bool? = nil, spans: [GMSStyleSpan]? = nil) {
let line = GMSPolyline(path: path)
line.strokeColor = strokeColor ?? line.strokeColor
line.strokeWidth = strokeWidth ?? line.strokeWidth
line.geodesic = geodesic ?? line.geodesic
line.spans = spans ?? line.spans
line.map = self
}
}
Usage:
let path = GMSMutablePath(coordinates: [<#Coordinates#>])
mapView.addPath(path)
- NOTE: You can create exact same line as google just once using tools out there or even google itself, store it somewhere and give it to your client as need.