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