Home | History | Annotate | Download | only in location
      1 page.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
     10 device'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
     17 Location</a></li>
     18   </ol>
     19   
     20   <h2>See Also</h2>
     21   <ol>
     22     <li><a
     23 href="http://code.google.com/android/add-ons/google-apis/maps-overview.html">Google
     24 Maps 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
     30 can build these capabilities into your applications using the classes of the {@link
     31 android.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
     37 the device through the classes in the {@code android.location} package. The
     38 central component of the location framework is the 
     39 {@link android.location.LocationManager} system service, which provides APIs to
     40 determine 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}
     43 directly. Rather, you request an instance from the system by calling
     44 {@link android.content.Context#getSystemService(String)
     45 getSystemService(Context.LOCATION_SERVICE)}. The method returns a handle to a new {@link
     46 android.location.LocationManager} instance.</p>
     47 
     48 <p>Once your application has a {@link android.location.LocationManager}, your application
     49 is 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
     53 user 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
     57 comes 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
     61 href="{@docRoot}guide/topics/location/obtaining-user-location.html">Obtaining User
     62 Location</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
     68 application, Google provides a Maps external library that includes the
     69 com.google.android.maps package. The classes of the com.google.android.maps
     70 package offer built-in downloading, rendering, and caching of Maps tiles, as
     71 well 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
     76 from the Google Maps service. When the MapView has focus, it will capture
     77 keypresses and touch gestures to pan and zoom the map automatically, including
     78 handling network requests for additional maps tiles. It also provides all of the
     79 UI elements necessary for users to control the map. Your application can also
     80 use MapView class methods to control the MapView programmatically and draw a
     81 number 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
     84 that lets your application manipulate Google Maps data through class methods,
     85 and 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
     88 may not be present on some compliant Android-powered devices. Similarly, the
     89 Maps external library is not included in the standard Android library provided
     90 in the SDK. So that you can develop using the classes of the
     91 com.google.android.maps package, the Maps external library is made available to
     92 you 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
     95 Google APIs add-on, visit</p>
     96 
     97 <p style="margin-left:2em;"><a
     98 href="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
    101 the Android SDK and AVD Manager (see <a href="{@docRoot}sdk/adding-components.html">Adding SDK
    102 Components</a>).</p>
    103 
    104 <p class="note"><strong>Note:</strong> In order to display Google Maps data in a
    105 MapView, you must register with the Google Maps service and obtain a Maps API
    106 Key. For information about how to get a Maps API Key, see <a
    107 href="http://code.google.com/android/add-ons/google-apis/mapkey.html">Obtaining
    108 a Maps API Key</a>.</p>
    109 
    110