IOS location and location information retrieval; ios Location Information Retrieval

Source: Internet
Author: User

IOS location and location information retrieval; ios Location Information Retrieval

To implement the map and navigation functions, you must first familiarize yourself with the positioning function and use the Core Location framework in iOS. Core Location can be used independently. It is completely independent from the map development framework MapKit. However, it is often used together with the positioning framework. The Core Location mainly includes the Location and Geographic Encoding (including anti-encoding) functions.

Positioning is a very common function. For example, if you allow the software to locate a map software after it is opened, the software is automatically locked to the current position after it is opened, if the user's mobile phone moves, the current location will also change. To implement this function, use the CLLocationManager class in Core Loaction. First, let's take a look at some of the main methods and attributes of this class:

 

IOS 8 also provides more user-friendly positioning service options. The App's location service is no longer just disabled or opened. Now, the activation of the location service provides three options: "never", "never", and "always 」. At the same time, considering the energy consumption, if an App requires that the positioning service be enabled in the background, iOS 8 will not only ask you when you open the App for the first time, in daily use, a pop-up window will pop up to remind you that the App has been using the location service in the background, and ask if you want to continue to allow. In iOS7 and earlier versions, if you use the location service in an application, you only need to call the startUpdatingLocation method in the application and then ask the user whether to allow the application to use the location service, at the same time, you can go to info. in plist, configurePrivacy-Location Usage DescriptionThis configuration is optional.
However, the configuration items in ios8.NSLocationAlwaysUsageDescriptionOrNSLocationWhenInUseUsageDescriptionTo tell the user the purpose of using the location service, and note that this configuration is required. If no configuration is made, the application cannot use the location service by default, opening an application does not prompt you to open the positioning service, unless you set the positioning service for the application after installation. In addition, the requestAlwaysAuthorization or locationServicesEnabled method needs to be requested in the application according to the configuration. Since my machine has been updated to the latest version of iOS8.1, the content below is mainly for iOS8, and friends who use iOS7 need to make some adjustments.

 

 

Next I will summarize the simple implementation of the positioning function.

Two dynamic libraries CoreLocation. framework and MapKit. framework must be loaded to locate and reverse query location information to obtain coordinates and provide reverse query.

In the. h file of RootViewController,

In the. m file of RootViewController,

The response method of the button. When the button is clicked, the equal position starts.

 

Agent method of locationManager

 

 

In iOS 6.0, map data is no longer driven by Google, but is switched to its own map. Of course, its data in China is provided by AMAP. In this way, the usage of map development before iOS6.0 will be different. Based on the current situation, there are actually few systems using versions earlier than iOS6.0, in the following content, we will not introduce the development of iOS5 and earlier versions of maps.

There are two main ways to develop maps in iOS: one is to directly use the MapKit framework for map development, which can be used to precisely control maps; the other method is to directly call the official map application provided by Apple, which is mainly used for some simple map applications (such as filling in the navigation cover) and cannot be precisely controlled. Of course, this section focuses on the former, and the subsequent content will be slightly prompted.

Before using MapKit, You Need To briefly understand some common attributes and methods of the Map Display Control MKMapView in MapKit, as shown in the following table:

 

 

See http://www.cnblogs.com/kenshincui/p/4125570.html for details

Related Article

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.