1

I'm developing an app to get the current location either when cellular data is off or when WiFi is not connected.

I used the following code, but I got only latitude and longitude not location with address.

so I need guidance to implement it.

     - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
           NSLog(@"didUpdateToLocation: %@", newLocation);
            CLLocation *currentLocation1 = newLocation;

    if (currentLocation1 != nil)
     {
        strLet=[NSString stringWithFormat:@"%f",currentLocation1.coordinate.latitude];
        strLong=[NSString stringWithFormat:@"%f",currentLocation1.coordinate.longitude];
        NSLog(@"%f",currentLocation1.coordinate.longitude);
       NSLog(@"%f",currentLocation1.coordinate.latitude);
     }  
}

Thanks.

Nitesh Borad
  • 4,583
  • 36
  • 51
Rakesh Thummar
  • 197
  • 1
  • 2
  • 11

1 Answers1

4

For your information, by using GPS, we can get current location without active internet connection, but it

(1) takes a long time to get position and (2) doesn't work properly inside buildings or streets

--- UPDATE (as question updated) ---

By using apple's native iOS API, you can do reverse geocoding by using MKReverseGeocoder (available in MapKit framework) or CLGeocoder (available in CoreLocation framework).
But, this require working internet connection for getting data from server.

So, you can't do reverse geocoding without internet connection using native iOS APIs.

However, by using following third party libraries, you can get limited available address information (Country Name and ISO Code):
IOS-Offline-GeoCoder
ios-offline-reverse-geocode-country,

Nitesh Borad
  • 4,583
  • 36
  • 51
  • but it return only latitude and longitude, can i get full address from longitude and latitude without internet connection? – Rakesh Thummar Jul 03 '14 at 13:17
  • I think this is probably limitation with GPS as I mentioned in (2) doesn't work properly inside buildings or streets .... But let me do some research on it and I will reply you correct answer.. – Nitesh Borad Jul 03 '14 at 13:25
  • **@ Nitesh Borad and Rakesh Thummar , did you get full address ?** If yes then please share your code. Thanks in advance. – Ravi Apr 08 '16 at 07:58
  • What this means? The last lines of above answer. if (newLocation.horizontalAccuracy < 0) { return; } NSTimeInterval interval = [newLocation.timestamp timeIntervalSinceNow]; if (abs(interval)>20) { return; } – Lydia Apr 30 '16 at 05:18
  • @Lydia: Thanks for your concern. I have removed those lines as they are not necessary. – Nitesh Borad May 02 '16 at 12:02
  • I did not mean that is not necessary, i was asking whats the use of that.Later i find out that gives accurate location after the interval of 20 sec, so thats lines may be good for who wishing to find the accurate location – Lydia May 03 '16 at 03:59
  • @Lydia: Actually, those lines were written to the old question in which questioner only asked about getting location coordinates with using GPS only. Yes, you got it right, that code was for finding accurate location. – Nitesh Borad May 03 '16 at 05:59
  • @NiteshBorad, The links you provide for third party libraries are giving only county, Did you get the full address by using latitude and longitude without Internet connection? – Ashok Jul 13 '16 at 17:51
  • @AshokKumarS: No. I didn't find any library providing full address data without Internet Connection till date. And it also seems very difficult to provide that much details for all countries in offline library as it consumes very much space (thousands of MB). However, if anyone provides, it will be very good. :) – Nitesh Borad Jul 14 '16 at 07:17