Preface
This chapter is the Framework Topics/Location and Maps chapter in the Android developer guide. It is translated into "Location and map" and the version is Android 4.0 r1. It is translated from: "beautiful life of the sun and fire ", welcome to his microblog: "http://alot.sinaapp.com", thank him again! We look forward to your participation in translation of Android related information, contact me over140@gmail.com.
Statement
You are welcome to repost, but please keep the original source of the article :)
Blog Garden: http://www.cnblogs.com/
Android Chinese translation group: http://androidbox.sinaapp.com/
Location and map
Translator's name: The beautiful life of the Sun and the fire
Link: http://alot.sinaapp.com
Version: Android 4.0 r1
Original
Http://developer.android.com/guide/topics/location/index.html
Location-Based and map-based applications are more eye-catching for mobile device users. You can useandroid.locationPackage classes and Google map extensions build this capability into your application. The following sections provide details.
Location service
Androidandroid.location The class in the package allows your application to access the location services supported by devices. The core component of the location framework is LocationManager System Service, which provides some application programming interfaces to determine the location and determine the direction of the underlying device (if available ).
Like other system services, do not instantiate them directly.LocationManager. Of course, you can callgetSystemService(Context.LOCATION_SERVICE)Requests an instance from the system. This method returns a new LocationManager Instance handle.
Once your application hasLocationManager You can do the following three things:
- Query all
LocationProviderTo obtain the latest user location.
- Regularly updates the current user location from a location provider registration/deregistration (specified by a condition or name ).
- The specified intention to be activated when the device is near the specified longitude/latitude range (specified by the radius of the meter unit.
For more information, read the user location guide.
Google map extension Library
To make it easier to add powerful map capabilities to applications, google provides a map extension library containing the com. google. android. maps package. The com. google. android. maps package class provides built-in download, rendering, and cache map fragmentation capabilities, as well as various display options and controls.
The main class in the map package iscom.google.android.maps.MapView, It is ViewGroup.MapView displays the map that carries the data obtained from the Google map service. When MapView gets the focus, it automatically captures keyboard keys and touch gestures to pan and zoom the map, including processing network requests for additional map fragments. It also provides all the necessary user interface elements for the user to control the map. Your application can also use the MapView method to program and control MapView and draw a certain number of modified styles on the map.
Generally, the MapView class provides the packaging of a Google Map application programming interface, which enables your application to operate Google map data using the class method, and when you want other types of views, it allows you to use map data.
The map extension library is not part of the standard Android library, so it may not exist on some compatible Android devices. Similarly, the map extension library is not included in the standard Android library provided by the SDK. The map extension library is provided for you as part of the Android SDK Google Application Programming Interface plug-in, so that you can use
To learn more about map extension libraries and how to download and use the Google Application Programming Interface plug-in, visit
Http://code.google.com/android/add-ons/google-apis
For your convenience, the Google Application Programming Interface plug-in can also be downloaded and used from the Android SDK and AVD Manager as downloadable components (see Adding SDK components ).
Note:: To display Google map data in a MapView, you must register Google map and obtain a map API Key ). For more information about how to obtain a map application programming interface Key, see obtain a map application programming interface Key (btaining a Maps API Key ).