IOS8 amap sdk MAMapView cannot be located
On iOS8 devices, you can use amap sdk to find that the callback position in MAMapView is empty.
-(void)mapView:(MAMapView*)mapView didUpdateUserLocation:(MAUserLocation*)userLocation updatingLocation:(BOOL)updatingLocation{ CLLocation *currentLocation = userLocation.location; if (currentLocation) { }}
CurrentLocation on iOS8 is empty, leading to locating failure. We know that Apple has greatly optimized its positioning on ios8. it can support indoor positioning, frequent location statistics, and floors.
Autonavi fails because it does not adapt to ios8.
Solution:
1. Add NSLocationWhenInUseDescription and NSLocationAlwaysUsageDescription to info. plist of the project. Different fields correspond to different methods.
2. Declare a private CLLocationManager variable in AppDelegate. m. The Code is as follows:
@interface AppDelegate()
{ UINavigationController *_navController; CLLocationManager *_locationmanager;}@end@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ [UIApplication sharedApplication].idleTimerDisabled = TRUE; _locationmanager = [[CLLocationManager alloc] init]; [_locationmanager requestAlwaysAuthorization]; //NSLocationAlwaysUsageDescription [_locationmanager requestWhenInUseAuthorization]; //NSLocationWhenInUseDescription _locationmanager.delegate = self;}
In this way, the callback in the MAMapView
-(void)mapView:(MAMapView*)mapView didUpdateUserLocation:(MAUserLocation*)userLocation updatingLocation:(BOOL)updatingLocation
You can get the user's current location normally. In this case, userLocation. location has a value.