Positioning for iPhone & iPod Touch

Source: Internet
Author: User
1. Use the showuserlocation attribute of uimapview.

Mymapview. showsuserlocation = Yes
After the display, read the coordinates, longitude, and latitude:
Self. userlocation. Coordinate. Latitude
Self. userlocation. Coordinate. longpolling

2. Use cllocationmanager

Locationmanager = [[cllocationmanager alloc] init];
Locationmanager. Delegate = self;
Locationmanager. desiredaccuracy = kcllocationaccuracybest; // select the optimal location
[Locationmanager startupdatinglocation];

After positioning, read the longitude and latitude in the delegate method:

-(Void) locationmanager :( cllocationmanager *) Manager
Didupdatetolocation :( cllocation *) newlocation
Fromlocation :( cllocation *) oldlocation

The first two methods are to use the core location framework to locate and select the final scheme based on the GPS, cell tower, and Wi-Fi sequence:

A. GPS Positioning: The accuracy can be up to 10 m;
B. cellular base stations: The accuracy is related to the density of local base stations;
C. Wi-Fi: IP addresses are used for locating, which is inaccurate and sometimes may contain errors of several miles. The iPhone's Wi-Fi positioning uses skyhook wireless to return the geographic coordinates of the corresponding IP address. Because the company's IP address is not included in the library, the iPhone's self-contained Wi-Fi positioning cannot be used;

3. Use the location service of Firefox and Safari:

Write an HTML file, load it with mapview, and use alert to return the obtained geographic coordinate information.
<HTML>
<Head>
<Title> know your current location </title>
<SCRIPT type = "text/JavaScript" src = "json2.js"> </SCRIPT>
<SCRIPT type = "text/JavaScript">
Navigator. geolocation. getcurrentposition (getlocation, unknownlocation );
 
Function getlocation (POS)
{
VaR latitde = pos. coords. Latitude;
VaR longpolling = pos. coords. longpolling;
Alert (JSON. stringify ({"latitude": latitde,
"Longtitude": longpolling }));
}
Function unknownlocation ()
{
Alert ('could not find location ');
}
</SCRIPT>
</Head>
</Html>

This method can achieve Wi-Fi positioning, but it is not accurate.

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.