Help passing found location to Maps.app

Discussion in 'iOS Programming' started by Pyro2b, Jan 11, 2009.

  1. macrumors newbie

    Joined:
    Aug 2, 2004
    Location:
    California
    #1
    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.
     
  2. macrumors 6502a

    sanPietro98

    Joined:
    May 30, 2008
    Location:
    28.416834,-81.581214
    #2
    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];
     

Share This Page