index.jd revision b00e37de181dc2f816962bc9301f64dd2a773c2a
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>In this document</h2> 15 <ol> 16 <li><a href="#location">Location Services</a></li> 17 <li><a href="#maps">Google Maps Android API</a></li> 18 </ol> 19 20</div> 21</div> 22 23<p>Location and maps-based apps offer a compelling experience on mobile devices. You 24can build these capabilities into your app using the classes of the {@link 25android.location} package and the Google Maps Android API. The sections below provide 26an introduction to how you can add the features. 27</p> 28 29<h2 id="location">Location Services</h2> 30 31<p>Android gives your applications access to the location services supported by 32the device through classes in the {@code android.location} package. The 33central component of the location framework is the 34{@link android.location.LocationManager} system service, which provides APIs to 35determine location and bearing of the underlying device (if available). </p> 36 37<p>As with other system services, you do not instantiate a {@link android.location.LocationManager} 38directly. Rather, you request an instance from the system by calling 39{@link android.content.Context#getSystemService(String) 40getSystemService(Context.LOCATION_SERVICE)}. The method returns a handle to a new {@link 41android.location.LocationManager} instance.</p> 42 43<p>Once your application has a {@link android.location.LocationManager}, your application 44is able to do three things:</p> 45 46<ul> 47 <li>Query for the list of all {@link android.location.LocationProvider}s for the last known 48user location.</li> 49 <li>Register/unregister for periodic updates of the user's current location from a 50 location provider (specified either by criteria or name).</li> 51 <li>Register/unregister for a given {@link android.content.Intent} to be fired if the device 52comes within a given proximity (specified by radius in meters) of a given lat/long.</li> 53</ul> 54 55<p>For more information about acquiring the user location, read the <a 56href="{@docRoot}guide/topics/location/strategies.html">Location Strategies</a> guide.</p> 57 58 59 60<h2 id="maps">Google Maps Android API</h2> 61 62<p>With the Google Maps Android API, you can add maps to your app that are based on Google 63Maps data. The API automatically handles access to Google Maps servers, data downloading, 64map display, and touch gestures on the map. You can also use API calls to add markers, 65polygons and overlays, and to change the user's view of a particular map area.</p> 66 67<p>The key class in the Google Maps Android API is 68<a href="{@docRoot}reference/com/google/android/gms/maps/MapView.html">{@code MapView}</a>. 69A <a href="{@docRoot}reference/com/google/android/gms/maps/MapView.html">{@code MapView}</a> 70displays a map with data obtained 71from the Google Maps service. When the 72<a href="{@docRoot}reference/com/google/android/gms/maps/MapView.html">{@code MapView}</a> 73has focus, it will capture 74keypresses and touch gestures to pan and zoom the map automatically, including 75handling network requests for additional maps tiles. It also provides all of the 76UI elements necessary for users to control the map. Your application can also 77use <a href="{@docRoot}reference/com/google/android/gms/maps/MapView.html">{@code MapView}</a> 78class methods to control the map programmatically and draw a 79number of overlays on top of the map. </p> 80 81<p>The Google Maps Android APIs are not included in the Android platform, 82but are available on any device 83with the Google Play Store running Android 2.2 or higher, through 84<a href="{@docRoot}google/play-services/index.html">Google Play services</a>.</p> 85 86<p>To integrate Google Maps into your app, you need to install the Google Play services 87libraries for your Android SDK. For more details, read about <a 88href="{@docRoot}google/play-services/index.html">Google Play services</a>.</p> 89 90 91