I have a button on my annotation that calls google maps as follows.
I’m trying to map a route from my known current location to the destination location passed from the annotation record.
The current location fails to be recognized in google maps and instead suggests a random place like Current, Dent, Missouri.
- (IBAction)GoogleMap
{
NSString *mapAddress = [NSString stringWithFormat:@"%@, %@, %@, %@",location.address, location.city, location.state, location.zipcode];
NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=Current+Location&daddr=%@",
// 40.7406578, -74.0020894, test coordinates
[mapAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
}
any idea where I am going wrong here? should this not work? Thanks.
As far as I am aware, typing “Current Location” into Google Maps does not actually send you to your current location.
I would suggest getting your current location using the method from this SO question and then passing the coordinates from the
CLLocationobject to Google Maps instead.