index.jd revision fa4596ec8028fa33d86d8e1d3bfa34bc736a8bb7
1page.title=Location and Maps
2@jd:body
3
4<div id="qv-wrapper">
5<div id="qv">
6
7  <h2>Quickview</h2>
8  <ul>
9    <li>Android provides a location framework that your application can use to determine the
10device's location and bearing and register for updates</li>
11    <li>A Google Maps external library is available that lets you display and manage Maps data</li>
12  </ul>
13
14  <h2>Topics</h2>
15  <ol>
16    <li><a href="{@docRoot}guide/topics/location/obtaining-user-location.html">Obtaining User
17Location</a></li>
18  </ol>
19  
20  <h2>See Also</h2>
21  <ol>
22    <li><a
23href="http://code.google.com/android/add-ons/google-apis/maps-overview.html">Google
24Maps External Library &raquo;</a></li>
25  </ol>
26</div>
27</div>
28
29<p>Location and maps-based applications are compelling for mobile device users. You
30can build these capabilities into your applications using the classes of the {@link
31android.location} package and the Google Maps external library. The sections below provide details.
32</p>
33
34<h2 id="location">Location Services</h2>
35
36<p>Android gives your applications access to the location services supported by
37the device through the classes in the {@code android.location} package. The
38central component of the location framework is the 
39{@link android.location.LocationManager} system service, which provides APIs to
40determine location and bearing of the underlying device (if available). </p>
41
42<p>As with other system services, you do not instantiate a {@link android.location.LocationManager}
43directly. Rather, you request an instance from the system by calling
44{@link android.content.Context#getSystemService(String)
45getSystemService(Context.LOCATION_SERVICE)}. The method returns a handle to a new {@link
46android.location.LocationManager} instance.</p>
47
48<p>Once your application has a {@link android.location.LocationManager}, your application
49is able to do three things:</p>
50
51<ul>
52    <li>Query for the list of all {@link android.location.LocationProvider}s for the last known
53user location.</li>
54    <li>Register/unregister for periodic updates of the user's current location from a
55    location provider (specified either by criteria or name).</li>
56    <li>Register/unregister for a given {@link android.content.Intent} to be fired if the device
57comes within a given proximity (specified by radius in meters) of a given lat/long.</li>
58</ul>
59
60<p>For more information, read the guide to <a
61href="{@docRoot}guide/topics/location/obtaining-user-location.html">Obtaining User
62Location</a>.</p>
63
64
65<h2 id="maps">Google Maps External Library</h2>
66
67<p>To make it easier for you to add powerful mapping capabilities to your
68application, Google provides a Maps external library that includes the
69com.google.android.maps package. The classes of the com.google.android.maps
70package offer built-in downloading, rendering, and caching of Maps tiles, as
71well as a variety of display options and controls. </p>
72
73<p>The key class in the Maps package is
74<code>com.google.android.maps.MapView</code>, a subclass of 
75{@link android.view.ViewGroup ViewGroup}. A MapView displays a map with data obtained
76from the Google Maps service. When the MapView has focus, it will capture
77keypresses and touch gestures to pan and zoom the map automatically, including
78handling network requests for additional maps tiles. It also provides all of the
79UI elements necessary for users to control the map. Your application can also
80use MapView class methods to control the MapView programmatically and draw a
81number of Overlay types on top of the map. </p>
82
83<p>In general, the MapView class provides a wrapper around the Google Maps API
84that lets your application manipulate Google Maps data through class methods,
85and it lets you work with Maps data as you would other types of Views.</p>
86
87<p>The Maps external library is not part of the standard Android library, so it
88may not be present on some compliant Android-powered devices. Similarly, the
89Maps external library is not included in the standard Android library provided
90in the SDK. So that you can develop using the classes of the
91com.google.android.maps package, the Maps external library is made available to
92you as part of the Google APIs add-on for the Android SDK. </p>
93
94<p>To learn more about the Maps external library and how to download and use the
95Google APIs add-on, visit</p>
96
97<p style="margin-left:2em;"><a
98href="http://code.google.com/android/add-ons/google-apis">http://code.google.com/android/add-ons/google-apis</a></p>
99
100<p>For your convenience, the Google APIs add-on is also available as a downloadable component from
101the Android SDK and AVD Manager (see <a href="{@docRoot}sdk/adding-components.html">Adding SDK
102Components</a>).</p>
103
104<p class="note"><strong>Note:</strong> In order to display Google Maps data in a
105MapView, you must register with the Google Maps service and obtain a Maps API
106Key. For information about how to get a Maps API Key, see <a
107href="http://code.google.com/android/add-ons/google-apis/mapkey.html">Obtaining
108a Maps API Key</a>.</p>
109
110