blob: 3217196676057d7f124e83e394832bd612aaf858 [file] [log] [blame]
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>In this document</h2>
<ol>
<li><a href="#location">Location Services</a></li>
<li><a href="#maps">Google Maps Android API</a></li>
</ol>
</div>
</div>
<p>Location and maps-based apps offer a compelling experience on mobile devices. You
can build these capabilities into your app using the classes of the {@link
android.location} package and the Google Maps Android API. The sections below provide
an introduction to how you can add the features.
</p>
<h2 id="location">Location Services</h2>
<p>Android gives your applications access to the location services supported by
the device through 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 about acquiring the user location, read the <a
href="{@docRoot}guide/topics/location/strategies.html">Location Strategies</a> guide.</p>
<h2 id="maps">Google Maps Android API</h2>
<p>With the Google Maps Android API, you can add maps to your app that are based on Google
Maps data. The API automatically handles access to Google Maps servers, data downloading,
map display, and touch gestures on the map. You can also use API calls to add markers,
polygons and overlays, and to change the user's view of a particular map area.</p>
<p>The key class in the Google Maps Android API is
<a href="{@docRoot}reference/com/google/android/gms/maps/MapView.html">{@code MapView}</a>.
A <a href="{@docRoot}reference/com/google/android/gms/maps/MapView.html">{@code MapView}</a>
displays a map with data obtained
from the Google Maps service. When the
<a href="{@docRoot}reference/com/google/android/gms/maps/MapView.html">{@code MapView}</a>
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 <a href="{@docRoot}reference/com/google/android/gms/maps/MapView.html">{@code MapView}</a>
class methods to control the map programmatically and draw a
number of overlays on top of the map. </p>
<p>The Google Maps Android APIs are not included in the Android platform,
but are available on any device
with the Google Play Store running Android 2.2 or higher, through
<a href="{@docRoot}google/play-services/index.html">Google Play services</a>.</p>
<p>To integrate Google Maps into your app, you need to install the Google Play services
libraries for your Android SDK. For more details, read about <a
href="{@docRoot}google/play-services/index.html">Google Play services</a>.</p>