user944351
user944351

Reputation: 1213

iOS open google maps route

I'm wondering why this is not working for cause there are a lot of examples on the web which exactly show the syntax how the maps app could be opened and a route can be displayed from a start to an endpoint.

But anyway, here is what i'm trying to do:

In my app i have a button and on when it's pressed, the maps app should be opened and the route from A to B should be displayed. So far so good. The only thing is, my starting point is my actual position in x/y coordinates and my end point is an adress. So i tried to form the url like this:

http://maps.google.com/maps?daddr=Mariahilferstraße+123+1000+Wien&saddr=43.213646,11.491927

And the the code that the maps app should open is this:

 UIApplication *app = [UIApplication sharedApplication];
 NSMutableString *url =  @"http://maps.google.com/maps?daddr=Mariahilferstraße+123+1000+Wien&saddr=43.213646,11.491927";
 [app openURL:[NSURL URLWithString:url]];

The maps app does not open....

Can anybody see a problem here and can help me?

Thanks a lot!

Upvotes: 0

Views: 969

Answers (1)

jcesarmobile
jcesarmobile

Reputation: 53301

for the geocoder (Is a simple geocoder, not reverse as I commented, reverse is for getting an address form lat/log)

[fgeo geocodeAddressString:@"Boston, MA"
            completionHandler:^(NSArray *placemarks, NSError *error){

             // Make sure the geocoder did not produce an error
             // before continuing
             if(!error){

                 // Iterate through all of the placemarks returned
                 // and output them to the console
                 for(CLPlacemark *placemark in placemarks){
                     NSLog(@"%@",[placemark description]);
                 }
             }
             else{
                 // Our geocoder had an error, output a message
                 // to the console
                 NSLog(@"There was a forward geocoding error\n%@",
                         [error localizedDescription]);
             }
         }
   ];

tutorial

Upvotes: 1

Related Questions