I have an App which launches the google Map App. The code is:
UIApplication *app = [UIApplication sharedApplication];
[app openURL:[[NSURL alloc] initWithString: @"http://maps.google.com/maps?daddr=Obere+Laube,+Konstanz,+Germany&saddr="]];
The saddr= should be the current location. I get the current location with
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSLog(@"%f,%f", [newLocation coordinate]);
The Log displays the correct coordinates like
2010-04-05 15:33:25.436 deBordeaux[60657:207] 37.331689,-122.030731
I didn’t find the right way to transmit the coordinates to the url-string. Does someone can give me a hint how-to?
Hmmm, I had the entry in my .h
In my method I use “newLocation” instead your “location”. The code is:
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
NSLog(@"%f,%f", [newLocation coordinate]);
NSLog(@"%f", [newLocation coordinate].latitude);
storedLocation = [newLocation coordinate];
NSLog(@"Standort neu String: %@", storedLocation);
As result I get :
- 2010-04-05 20:28:44.397 deBordeaux[64179:207] 37.331689,-122.030731
- 2010-04-05 20:28:44.398 deBordeaux[64179:207] 37.331689
- Program received signal: “EXC_BAD_ACCESS”.
You shouldn’t use addr parameter of the URL but ll.
You should pass latitude and longitude as
and you can obtain them from the
CLocationthroughtEDIT:
First of all you can directly store an object of type
CLLocationCoordinate2Dand then convert it to a NSString when you need:Mind that
CLLocationCoordinate2Dis defined aswhere you have
typedef double CLLocationDegrees