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