0

I am calling Google Maps app to show directions between "Current Location" and another location. I am using the following code,

NSString* url = [NSString stringWithFormat: 
                 @"http://maps.google.com/maps?saddr=%@&daddr=%f,%f", 
                 @"Current\%20Location", 
                 destCoordinate.latitude, destCoordinate.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];

Note that I am passing @"Current\%20Location" as saddr. This works fine if my phone's Language is set to English. @pazustep, here, in my post regarding finding Current Location, suggested that this wont work if the Language is different. And obviously, to solve this issue, I have to use Core Location to find the current location and pass the latitude and longitude to Google Maps app. But I am expecting some other way to solve this issue without modifying the implementation logic.

  1. Is there any built-in API available to translate the string "Current Location" , or any string, into the current phone Language?
  2. If not, Is there a way to tell Google Maps app to translate the string to the current language?
Dylan Brown
  • 35
  • 1
  • 10
EmptyStack
  • 51,274
  • 23
  • 147
  • 178
  • I like this question, but I figure that you're going to end up translating the string with some other web service. Have you tried adding the &hl=en parameter to the URL so that the search gets performed in english? – Aurum Aquila Feb 09 '11 at 07:26
  • @Aurum Aquila: Now I tried this.. It doesn't work though.. – EmptyStack Feb 09 '11 at 09:23
  • Why are you escaping the `%` with a ` \ ` – JeremyP Feb 09 '11 at 11:51
  • @JeremyP: This post has the answer for your question.. http://stackoverflow.com/questions/4590972/open-maps-app-from-code-where-how-to-find-the-current-location/4591072#4591072 – EmptyStack Feb 09 '11 at 12:04
  • 1
    @Simon: You are not doing format substitution on the string `@"Current%20Location"` In any case, the correct escape for `%` in format strings is `%%` http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265-SW2 – JeremyP Feb 09 '11 at 13:53

1 Answers1

1

Why not use core location to get the latitude and longitude of the current location and put that in to saddr?

JeremyP
  • 84,577
  • 15
  • 123
  • 161