1

I'm developing with MKMapView class, When running on the device (iPhone5) and with AirPlane mode ON , Wi-Fi ON,

and the property of MKMapView:showsUserLocationsetting to YES,the delegate of MKMapView

- (void)mapView:(MKMapView *)mapView didFailToLocateUserWithError:(NSError *)error

is called, returning an error

Turn off airplane mode or use Wi-Fi to show your location on the map

telling me to turn of AirPlane mode or Turn on Wi-Fi to get location on the map. My Airplane mode is on, but my Wi-Fi is Enabled, why can't I locate my position?

Is it a bug of MKMapView,or something else? thanks!

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Johnny
  • 2,589
  • 2
  • 27
  • 34

2 Answers2

1

The apple documentation says

Determining Whether Location Services Are Available

Every iOS-based device is capable of supporting location services in some form but there are still situations where location services may not be available:

The user can disable location services in the Settings app.

The user can deny location services for a specific app.

The device might be in Airplane mode and unable to power up the necessary hardware. For these reasons, it is recommended that you always call the locationServicesEnabled class method of CLLocationManager before attempting to start either the standard or significant-change location services. (In iOS 3.x and earlier, check the value of the locationServicesEnabled property instead.) If this class method returns YES, you can start location services as planned. If it returns NO and you attempt to start location services anyway, the system prompts the user to confirm whether location services should be reenabled. Given that location services are very likely to be disabled on purpose, the user might not welcome this prompt.

Nope not a bug it is said explicitly in the docs how to do it

Community
  • 1
  • 1
Lithu T.V
  • 19,955
  • 12
  • 56
  • 101
0

I believe that when the airplane mode is switched on it turns off all the possible ways to track your position, wi-fi included.

You can try it with your device by switching the airplane mode on while connected to the internet via wi-fi and accessing any webpage via safari.

jonypz
  • 1,515
  • 1
  • 20
  • 35
  • I have the same thinking at the beginning, but the built-in map in iPhone, or Google Maps, or other apps that requires location service works fine... – Johnny Jun 19 '13 at 10:29
  • It probably caches your position from time to time. I don't think that's a bug: if you are switching off all the tracking possibilities, how would you be able to find the device's position? – jonypz Jun 19 '13 at 10:34
  • but I've tried many times on different devices, Turn on Airplane mode, then turn on Wi-Fi, Connect to Wi-Fi. and Enable location service, open Google Map or Apple map start locate my position, it works everytime... – Johnny Jun 19 '13 at 10:41
  • Could you try it for me on your phone? – Johnny Jun 19 '13 at 10:41
  • I don't have any wifi available to try. I would say that if what you are sayng is accurate, the error message probably is not the desired one and there is in fact some kind of bug. – jonypz Jun 19 '13 at 10:52
  • In addition, you could re-formulate your test by switching the airplane and wifi on, change your location and test with google maps' app. – jonypz Jun 19 '13 at 10:56
  • Tried moving my location, the result comes same, it's not cache. – Johnny Jun 19 '13 at 13:28
  • http://goo.gl/dTkVV this thread is having the same question... but seemed not solved – Johnny Jun 19 '13 at 13:28