Reputation: 725
Is it possible to draw routes between the user's current location and the destination chosen, using Google Maps SDK for iOS ? I've read in many webpages that google does not allow this, is that true ? If so, how it comes that this is possible with the Google Maps app for iPhone ?
Please share your thoughts.
Upvotes: 1
Views: 4016
Reputation: 427
Yes, using following code you can get the GMSPolyline
object which you can add to Google map by setting its map property.
+(GMSPolyline *)googlePolylineWithGoogleEncoded:(NSString *)encodedString
{
GMSMutablePath *path = [GMSMutablePath pathFromEncodedPath:encodedString];
GMSPolyline *polyline = [GMSPolyline polylineWithPath:path];
return polyline;
}
Upvotes: 0
Reputation: 2551
The Maps SDK allows you to draw Polylines on your map. See https://developers.google.com/maps/documentation/ios/shapes
The Google Directions API gives you Polylines when you query directions from location A to B. See https://developers.google.com/maps/documentation/directions/#JSON
I don't think the Maps SDK can directly use the format given by the Direction API though, you will have to handle this yourself. See this thread for a solution to this : How to decode the Google Directions API polylines field into lat long points in objective-C for iPhone?
Hope this helps!
Upvotes: 1