| page.title=Location and Maps |
| @jd:body |
| |
| <div id="qv-wrapper"> |
| <div id="qv"> |
| |
| <h2>Quickview</h2> |
| <ul> |
| <li>Android provides a location framework that your application can use to determine the |
| device's location and bearing and register for updates</li> |
| <li>A Google Maps external library is available that lets you display and manage Maps data</li> |
| </ul> |
| |
| <h2>Topics</h2> |
| <ol> |
| <li><a href="{@docRoot}guide/topics/location/obtaining-user-location.html">Obtaining User |
| Location</a></li> |
| </ol> |
| |
| <h2>See Also</h2> |
| <ol> |
| <li><a |
| href="http://code.google.com/android/add-ons/google-apis/maps-overview.html">Google |
| Maps External Library »</a></li> |
| </ol> |
| </div> |
| </div> |
| |
| <p>Location and maps-based applications are compelling for mobile device users. You |
| can build these capabilities into your applications using the classes of the {@link |
| android.location} package and the Google Maps external library. The sections below provide details. |
| </p> |
| |
| <h2 id="location">Location Services</h2> |
| |
| <p>Android gives your applications access to the location services supported by |
| the device through the classes in the {@code android.location} package. The |
| central component of the location framework is the |
| {@link android.location.LocationManager} system service, which provides APIs to |
| determine location and bearing of the underlying device (if available). </p> |
| |
| <p>As with other system services, you do not instantiate a {@link android.location.LocationManager} |
| directly. Rather, you request an instance from the system by calling |
| {@link android.content.Context#getSystemService(String) |
| getSystemService(Context.LOCATION_SERVICE)}. The method returns a handle to a new {@link |
| android.location.LocationManager} instance.</p> |
| |
| <p>Once your application has a {@link android.location.LocationManager}, your application |
| is able to do three things:</p> |
| |
| <ul> |
| <li>Query for the list of all {@link android.location.LocationProvider}s for the last known |
| user location.</li> |
| <li>Register/unregister for periodic updates of the user's current location from a |
| location provider (specified either by criteria or name).</li> |
| <li>Register/unregister for a given {@link android.content.Intent} to be fired if the device |
| comes within a given proximity (specified by radius in meters) of a given lat/long.</li> |
| </ul> |
| |
| <p>For more information, read the guide to <a |
| href="{@docRoot}guide/topics/location/obtaining-user-location.html">Obtaining User |
| Location</a>.</p> |
| |
| |
| <h2 id="maps">Google Maps External Library</h2> |
| |
| <p>To make it easier for you to add powerful mapping capabilities to your |
| application, Google provides a Maps external library that includes the |
| com.google.android.maps package. The classes of the com.google.android.maps |
| package offer built-in downloading, rendering, and caching of Maps tiles, as |
| well as a variety of display options and controls. </p> |
| |
| <p>The key class in the Maps package is |
| <code>com.google.android.maps.MapView</code>, a subclass of |
| {@link android.view.ViewGroup ViewGroup}. A MapView displays a map with data obtained |
| from the Google Maps service. When the MapView has focus, it will capture |
| keypresses and touch gestures to pan and zoom the map automatically, including |
| handling network requests for additional maps tiles. It also provides all of the |
| UI elements necessary for users to control the map. Your application can also |
| use MapView class methods to control the MapView programmatically and draw a |
| number of Overlay types on top of the map. </p> |
| |
| <p>In general, the MapView class provides a wrapper around the Google Maps API |
| that lets your application manipulate Google Maps data through class methods, |
| and it lets you work with Maps data as you would other types of Views.</p> |
| |
| <p>The Maps external library is not part of the standard Android library, so it |
| may not be present on some compliant Android-powered devices. Similarly, the |
| Maps external library is not included in the standard Android library provided |
| in the SDK. So that you can develop using the classes of the |
| com.google.android.maps package, the Maps external library is made available to |
| you as part of the Google APIs add-on for the Android SDK. </p> |
| |
| <p>To learn more about the Maps external library and how to download and use the |
| Google APIs add-on, visit</p> |
| |
| <p style="margin-left:2em;"><a |
| href="http://code.google.com/android/add-ons/google-apis">http://code.google.com/android/add-ons/google-apis</a></p> |
| |
| <p>For your convenience, the Google APIs add-on is also available as a downloadable component from |
| the Android SDK and AVD Manager (see <a href="{@docRoot}sdk/adding-components.html">Adding SDK |
| Components</a>).</p> |
| |
| <p class="note"><strong>Note:</strong> In order to display Google Maps data in a |
| MapView, you must register with the Google Maps service and obtain a Maps API |
| Key. For information about how to get a Maps API Key, see <a |
| href="http://code.google.com/android/add-ons/google-apis/mapkey.html">Obtaining |
| a Maps API Key</a>.</p> |
| |