IOS8 amap sdk MAMapView cannot be located

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.