OC Development _storyboard--mapkit

Source: Internet
Author: User

First, Core location

1. Basic objects

@propertys: Coordinate, altitude, horizontal/verticalaccuracy, timestamp, speed, course

@property (readonly) cllocationcoordinate2d coordinate;

typedef {

Cllocationdegrees latitude; Type Double latitude

Cllocationdegrees longitude; Double type Longitude

} cllocationcoordinate2d;

@property (readonly) cllocationdistance altitude; Height (unit: m)

2. Accuracy

Kcllocationaccuracybestfornavigation//accuracy is best, but at the same time the most power consumption, the following analogy

Kcllocationaccuracybest

Kcllocationaccuracynearesttenmeters

Kcllocationaccuracyhundredmeters

Kcllocationaccuracykilometer

Kcllocationaccuracythreekilometers

3. How to get core location? [By Cllocationmanager]

The usual steps are: (1 hardware-based support (2 create a Cllocationmanager instance and set the delegate (3 configuration How to update, precision (4 to open this manager to run

4. When you first create Location manager, you need to check for these items:

+ (clauthorizationstatus)authorizationstatus; * Check the app's authorization status * When the app is first started, the authorization is automatically requested, the app should be explicitly authorized to use the location service, and the location service is currently running in order for the app to use the location service.

+ (BOOL)locationservicesenabled; * determine if the user started the location service * Before starting the location update operation, the user should check the return value of the method to see if the device's location service is started. If the location service does not start and the user initiates a location update, the core location framework will pop up a dialog box that allows the user to confirm whether to start the position service.

+ (BOOL)significantlocationchangemonitoringavailable; * Indicates whether the device can report an update based on significant location changges *(significant site change monitoring, based only on the position of the cellular tower linked to the device, When the accuracy requirement is not high, can save a lot of power. )

+ (BOOL)ismonitoringavailableforclass:(Class) Regionclass; //monitoring of certain device beacons

+ (BOOL)israngingavailable; //*  returns whether the Bluetooth signal range service is available *. This is the new method for iOS 7

5. Commission

(1 properties

@property cllocationaccuracy desiredaccuracy; Precision

@property cllocationdistance distancefilter; Distance filter: How far beyond the distance to start repositioning

(2 positioning

-(void)startupdatinglocation; Turn on positioning
-(void)stopupdatinglocation; Turn off positioning

-(void)startmonitoringsignificantlocationchanges; You can monitor the movement of the user's location in the background or in the foreground, even if the program does not start

-(void)stopmonitoringsignificantlocationchanges; // 

(3 When your program is not running or the background is started, this method will be sent

application:didfinishlaunchingwithoptions: Uiapplicationlaunchoptionslocationkey

(4 circular range [based on area monitoring]

-(void)startmonitoringforregion:(clregion *) region; Clcircularregion/clbeaconregion

-(void)stopmonitoringforregion:(clregion *) region;

When you enter the range, you will be sent a broadcast to notify you [this is iOS7 new]

-(void) Locationmanager: (Cllocationmanager *) Manager didenterregion:(clregion *) region;

-(void) Locationmanager: (Cllocationmanager *) Manager didexitregion:(clregion *) region;

-(void) Locationmanager: (Cllocationmanager *) Manager monitoringdidfailforregion:(clregion *) region

Witherror: (Nserror *) error;

Then you can talk about Mapkit:

Second, Mkmapview

1, annotations: by clicking will pop up a Mkannotationview

@property (readonly) Nsarray *annotations;

@protocol mkannotation <NSObject>

@property (readonly) cllocationcoordinate2d coordinate;//

@optional

@property (readonly) NSString *title; Title

@property (readonly) nsstring *subtitle;//subtitle

@end

typedef {

Cllocationdegrees latitude;

Cllocationdegrees longitude;//latitude and longitude

} cllocationcoordinate2d;

2, Mkannotationview

@property ID <MKAnnotation> annotation;

@property UIImage *image; You can modify a picture of a pin like
@property UIView *leftcalloutaccessoryview; Changes to pop-up view
@property UIView *rightcalloutaccessoryview;

@property BOOL enabled;

@property Cgpoint Centeroffset;

@property BOOL draggable;

(1 [very much like UITableView] Create a view (not created will be created automatically)

-(Mkannotationview *) Mapview: (Mkmapview *) sender viewforannotation:(ID <MKAnnotation>) annotation

{

mkannotationview *aview = [Sender dequeuereusableannotationviewwithidentifier:ident];

if (!aview) {

Aview = [[Mkpinannotationview alloc] Initwithannotation:annotation

Reuseidentifier:ident];

aview.annotation = annotation;

return aview;

}

(2 view inside icon is tap event

-(void) Mapview: (Mkmapview *) sender Annotationview:(Mkannotationview *) Aview

calloutaccessorycontroltapped: (Uicontrol *) control;

(3 pins are lightly lit events

-(void) Mapview: (Mkmapview *) sender Didselectannotationview:(Mkannotationview *) Aview

{

if ([Aview.leftcalloutaccessoryview Iskindofclass:[uiimageview class]])

{

Uiimageview *imageview = (Uiimageview *) Aview.leftcalloutaccessoryview;

Imageview.image = ...;

}

}

(4 Call Camera action

+ (Mkmapcamera *)cameralookingatcentercoordinate:(cllocationcoordinate2d) coord

Fromeyecoordinate: (cllocationcoordinate2d) cameraposition

Eyealtitude: (cllocationdistance) eyealtitude;

(5 animation effect: For example, the relocation of the location , first from the top of the transfer, and then from top to bottom

-(void) Mapview: (Mkmapview *) Mapview didchangeregionanimated: (BOOL) animated;

3, Mklocalsearch Search

(1 Search

mklocalsearchrequest *request = [[Mklocalsearchrequest alloc] init];

Request.naturallanguagequery = @ "Ike ' s";

Request.region = ...;

mklocalsearch *search = [[Mklocalsearch alloc] initwithrequest:request];

[Search Startwithcompletionhandler: ^ (mklocalsearchresponse *response, Nserror *error) {// get a Mkmapitem array, which also contains Mkplacemark }];

(2 opens in the Map app

-(BOOL)openinmapswithlaunchoptions:(nsdictionary *) options;

4. Mkdirections Route

Third, Embed Segue
Container View

OC Development _storyboard--mapkit

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.