Ios-gps Positioning Basics

Source: Internet
Author: User

IOS-GPS Location Services and map applications are two completely different sets of APIs.

Four location services for IOS 7

    • GPS satellite advantages of the most accurate, the shortcomings of power consumption, can not be obscured (not in the building)
    • Wi-Fi via WiFi router location advantages Compare power saving, economical
    • Cellular mobile phone Base station. The location error ratio of Base station is large by mobile operator
    • Ibeacon micro-positioning. Apple has developed its own ibeacon, using low-power Bluetooth.
iOS Location Service development does not need to specify the location path (in addition to micro-positioning) iOS will be based on the situation of the device to adopt the best plan, if you can accept GPS priority GPS positioning, followed by Wi-Fi, and finally cellular base station positioning;
IOS 7 Location services using the core geolocation framework
    • Cllocationmanager is used to locate the management of the class, he provides location information and height information, you can also monitor the device into or out of a certain area, but also to obtain the direction of the device operation;
    • Cllocationmanagerdelegate. The entrustment agreement of the Cllocationmanager class;
    • The cllocation encapsulates position and height information;
the first time the location information is requested, the user is prompted to allow location services to be enabled.

<span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:12PX;" >-(void) viewdidload{    [Super Viewdidload];    Locationmanager = [[Cllocationmanager alloc]init];    Locationmanager.delegate = self;    Locationmanager.desiredaccuracy = kcllocationaccuracybest;    Locationmanager.distancefilter = 1000.F;} </span>
Initialize a location manager to set up a good proxy

Desireaccuracy This property is used to set the longitude

<span style= "FONT-FAMILY:SIMSUN;FONT-SIZE:12PX;" >kCLLocationAccuracyBest; The highest precision of battery-powered kcllocationaccuracynearesttenmeters; Accurate to 10 m kcllocationaccuracyhundredmeters, accurate to 100 m kcllocationaccuracykilometer; Accurate to 1000 m kcllocationaccuracythreekilometers; 3000 m </span>

The higher the longitude, the less time it takes to get information. The more power you consume.

The Distabcefilter attribute defines the minimum distance, in meters, of the location information that is obtained after the device is moved;

Set the distance filter Distancefilter to indicate that the device is moving at least 1000 meters before notifying the delegate to update

Open and close the location service separately when the view is displayed

-(void) Viewwillappear: (BOOL) animated{    [Super viewwillappear:animated];    [Locationmanager startupdatinglocation];} -(void) Viewwilldisappear: (BOOL) animated{    [Super viewwilldisappear:animated];    [Locationmanager stopupdatinglocation];}

Call the proxy to get the data when the acquisition location succeeds

-(void) Locationmanager: (Cllocationmanager *) Manager didupdatelocations: (Nsarray *) locations{    cllocation * currentlocation = [Locations lastobject];    Double  altitude = currentlocation.altitude;//height    double  latitude = currentLocation.coordinate.latitude;    Double  longitude = currentLocation.coordinate.longitude;}

The lication in the agent is an array of positional data, and the last one is the current position;

Cllocation class

initialization function –initwithlatitude:longitude:–initwithcoordinate:altitude:horizontalaccuracy:verticalaccuracy:timestamp:– InitWithCoordinate:altitude:horizontalAccuracy:verticalAccuracy:course:speed:timestamp: Properties: Coordinate property     geographic coordinates altitude property height horizontalaccuracy The radius of the circle verticalaccuracy the precision of the property's vertical height timestamp Time –distancefromlocation: Specifies the distance from the position to the current position the speed of the property    Movement course the direction of the property device

Cllocation encapsulates the position, height, and other information  altitude is the height value coordinate is the structure of the encapsulated latitude and longitude cllocationcoordinate2dtypedef struct { Cllocationdegrees latitude;  Longitude cllocationdegrees longitude;//latitude} cllocationcoordinate2d; Cllocationdegrees is a double type alias

All above from Dongsheng teacher iOS Development Guide

Ios-gps Positioning Basics

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.