Geocode forwarding

3 views
Skip to first unread message

William Frowine

unread,
Feb 22, 2012, 7:11:59 PM2/22/12
to pdx-cocoa...@googlegroups.com
HI All:

Does anyone know anything about Geocode forwarding.  I am trying to take a address string bounce it against the geocoder and return the latitude and longitude.  I tried the following code but it does not like the info below the block.  Does anyone have any suggestions?

//Geocoding 
   NSString *breweryaddress = [NSString stringWithFormat:@"%@ %@ %@ ", name.text, addressid.text, csz.text];

 CLGeocoder *geocoder = [[[CLGeocoder alloc] init] autorelease];

    [geocoder geocodeAddressString:breweryaddress completionHandler:^

     (NSArray *placemarks, NSError *error)

    { }];

 

//code to grab the lat / lon   

    CLPlacemark *placemarks = [placemarks objectAtIndex:0];

    

    lat = placemarks.latitude;
    lon = placemarks.longitude;

    

Amit Kumar

unread,
Feb 22, 2012, 7:43:36 PM2/22/12
to pdx-cocoa...@googlegroups.com
I'd change this to:

        //Geocoding 
        NSString *breweryaddress = [NSString stringWithFormat:@"%@ %@ %@ ", name.text, addressid.text, csz.text];
        CLGeocoder *geocoder = [[[CLGeocoder alloc] init] autorelease];
        [geocoder geocodeAddressString:breweryaddress completionHandler:^
         (NSArray *placemarks, NSError *error)
         { 
             if (!error && [placemarks count])
             {

William Frowine, PMP

unread,
Feb 22, 2012, 7:59:42 PM2/22/12
to pdx-cocoa...@googlegroups.com
Thanks Amit:

Are these two lines the correct attributes for latitude ;/ longitude

lat = placemarks.latitude;
                 lon = placemarks.longitude;
       

Amit Kumar

unread,
Feb 22, 2012, 8:20:38 PM2/22/12
to pdx-cocoa...@googlegroups.com
No. It'll be placemark.location.coordinate.latitude and placemark.location.coordinate.longitude, where placemark is an object from placemarks array.

Northwest Mobile Development LLC

unread,
Feb 23, 2012, 12:31:48 PM2/23/12
to pdx-cocoa...@googlegroups.com
Thanks Amit!

I think that will do the trick!
----------------
William Frowine, PMP
Northwest Mobile Development LLC
in...@nwmobiledev.com

Reply all
Reply to author
Forward
0 new messages