PDA

View Full Version : Help passing found location to Maps.app




Pyro2b
Jan 11, 2009, 10:51 PM
Hi, I am trying to pass the found location to the maps.app, but for some reason, the string passed to the map shows a location of "0.0000, 0.0000" instead of the correct Lat and Long the CLLocation manager just found. Here is my code:

{
if (wasFound) return;
wasFound = YES;

CLLocationCoordinate2D loc = [newLocation coordinate];

latitude.text = [NSString stringWithFormat: @"%f", loc.latitude];
longitude.text = [NSString stringWithFormat: @"%f", loc.longitude];
altitude.text = [NSString stringWithFormat: @"%f", newLocation.altitude];
}
-(IBAction)openMaps{
NSString *mapUrl = [NSString stringWithFormat: @"http://maps.google.com/maps?q=%f,%f"];
NSURL *url = [NSURL URLWithString:mapUrl];
[[UIApplication sharedApplication] openURL:url];
}


Can anyone tell me what I am doing wrong? What am I missing? Thanks for any help.



sanPietro98
Jan 12, 2009, 07:25 AM
NSString *mapUrl = [NSString stringWithFormat: @"http://maps.google.com/maps?q=%f,%f"];


You aren't supplying values for the two floats. It should be something like:

NSString *mapUrl = [NSString stringWithFormat: @"http://maps.google.com/maps?q=%f,%f",latitudeValue,longitudeValue];