Corelocation geo-Location Map Kit Map Show

Source: Internet
Author: User

Here is a summary of the map positioning knowledge. Corelocaton,map Kit.

In the era of mobile internet, mobile apps can solve many of the user's life chores, such as
Navigation: Go to any unfamiliar place
Nearby: Find a restaurant, find a hotel, find a bank, find a cinema

In the above applications, maps and positioning functions are used, in iOS development, in order to join the 2 major functions, must be based on 2 frameworks for development
Map Kit: For maps
Core Location: For geolocation

2 Hot Technical Terms
Lbs:location Based Service
Solomo:social Local Mobile (Solomon)



Use of the Corelocation framework

Corelocation Framework Usage Prerequisites
Import Frame Corelocation

Import Primary header file
#import <CoreLocation/CoreLocation.h>

Corelocation Framework Usage Notes
The prefix for all data types in the Corelocation framework is CL
Using Cllocationmanager objects in corelocation to do user positioning

Common operations for Cllocationmanager
Start user targeting
-(void) startupdatinglocation;

Stop user Targeting
-(void) stopupdatinglocation;

When the Startupdatinglocation method is called, the user's location is started constantly, and the agent's method is called frequently in the middle
-(void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) locations;
The locations parameter contains the Cllocation object.

Cllocation the geographic information used to represent a location, such as latitude and longitude, altitude, etc.
@property (readonly, nonatomic) Cllocationcoordinate2d coordinate; Warp latitude
@property (readonly, nonatomic) cllocationdistance altitude; Elevation
@property (readonly, nonatomic) Cllocationdirection course;
Course, course (value range is 0.0°~ 359.9°,0.0° represents true north direction)
@property (readonly, nonatomic) cllocationspeed speed;
Travel speed (unit m/s)

With-(cllocationdistance) Distancefromlocation: (const cllocation *) Location

The above method can calculate the distance between 2 positions

@property (Assign, nonatomic) cllocationdistance distancefilter;
How many meters to locate each time

@property (Assign, nonatomic) cllocationaccuracy desiredaccuracy;
Positioning accuracy (the more accurate it consumes)

Cllocationcoordinate2d is a structure used to represent latitude and longitude, defined as follows
typedef struct {
Cllocationdegrees latitude; Latitude
Cllocationdegrees longitude; Longitude
} cllocationcoordinate2d;
The Cllocationcoordinate2dmake function is generally used to create cllocationcoordinate2d


If the simulator, you need to set the analog location (latitude and longitude)

Starting with iOS 6, Apple has done a great job of protecting the privacy of its users, and the following must be authorized by user approval
To get the user's location
Want to access users ' contacts, calendars, cameras, albums, and more
When you want to access the user's privacy information, the system will automatically pop up a dialog box to let the user authorize


Developers can set nslocationusagedescription instructions for positioning in Info.plist (privacy-location Usage Description)

Once the user chooses "Don't allow", it means your app won't be able to use the targeting feature
For the sake of rigor, it's a good idea to determine if the current app's positioning function is available before using the location feature
Cllocationmanager has a class method to determine if the current app's positioning function is available
+ (BOOL) locationservicesenable;


Clgeocoder

Use Clgeocoder to complete geocoding and anti-geocoding
Geocoding: Obtain specific location information (such as latitude and longitude, full name of address, etc.) based on a given place name
Anti-geocoding: Obtain specific location information based on a given latitude and longitude

Geo-coding methods
-(void) geocodeaddressstring: (NSString *) addressstring Completionhandler:

(Clgeocodecompletionhandler) Completionhandler;

Anti-geocoding methods
-(void) Reversegeocodelocation: (cllocation *) Location Completionhandler:

(Clgeocodecompletionhandler) Completionhandler;


When Geo-geocoding is complete, the Clgeocodecompletionhandler is called
typedef void (^clgeocodecompletionhandler) (Nsarray *placemarks, Nserror *error);
This block passes 2 parameters
Error: There is a value when the encoding is wrong (for example, no specific information is encoded)
Placemarks: It contains Clplacemark objects.

Clplacemark

Clplacemark literally means a landmark, encapsulating detailed address location information
@property (nonatomic, readonly) cllocation *location; Location
@property (nonatomic, readonly) clregion *region; Regional
@property (nonatomic, readonly) nsdictionary *addressdictionary; Detailed address information
@property (nonatomic, readonly) NSString *name; Address name
@property (nonatomic, readonly) NSString *locality; City

Corelocation geo-Location Map Kit Map Show

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.