Map location Information

Source: Internet
Author: User


// Create location service object

Locationmanager = [[cllocationmanager alloc] init];

Locationmanager. Desiredaccuracy = kcllocationaccuracybest;

// set up a location agent

Locationmanager. Delegate = self;

// If it's really iOS8.0 , we need to add the following:

//1. Call method --requestwheninuseauthorization or requestalwaysauthorization

//2.

if ([uidevice currentdevice]. Systemversion. Floatvalue >= 8.0) {

[locationmanager requestwheninuseauthorization];

}

// start positioning

[locationmanager startupdatinglocation];

}


-(void) didreceivememorywarning {

[super didreceivememorywarning];

//Dispose of any resources, can be recreated.

}


#pragma mark-cllocationmanagerdelegate

-(void) Locationmanager: (cllocationmanager *) Manager didupdatetolocation: (cllocation *) NewLocation fromlocation: (cllocation *) oldlocation

{

NSLog (@ " positioning success ");

// stop positioning

[locationmanager stopupdatinglocation];

cllocationcoordinate2d coordinate = newlocation. coordinate;

NSLog (@ " location: Latitude:%.2f---- Longitude:%.2f", coordinate. latitude, coordinate. longitude);

}


-(void) Locationmanager: (cllocationmanager *) Manager

Didupdatelocations: (nsarray *) Locations

{

NSLog(@ " New method Positioning success ");

// stop positioning

[locationmanager stopupdatinglocation];

cllocation *location = [Locations lastobject];

cllocationcoordinate2d coordinate = location. coordinate;


NSLog (@ " location: Latitude:%.2f---- Longitude:%.2f", coordinate. latitude, coordinate. longitude);


}


Map location Information

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.