Google Maps Android API

Introduction to the Google Maps Android API v2

With the Google Maps Android API, you can add maps based on Google Maps data to your application. The API automatically handles access to Google Maps servers, data downloading, map display, and response to map gestures. You can also use API calls to add markers, polygons, and overlays to a basic map, and to change the user's view of a particular map area. These objects provide additional information for map locations, and allow user interaction with the map. The API allows you to add these graphics to a map:

  • Icons anchored to specific positions on the map (Markers).
  • Sets of line segments (Polylines).
  • Enclosed segments (Polygons).
  • Bitmap graphics anchored to specific positions on the map (Ground Overlays).
  • Sets of images which are displayed on top of the base map tiles (Tile Overlays).

Audience

This documentation is designed for people familiar with Android development and object-oriented programming concepts. You should also be familiar with Google Maps from a user's point of view.

This conceptual documentation is designed to let you quickly start exploring and developing applications with the Google Maps Android API. You may also wish to refer to the reference documentation for specific details of classes and methods.

Google Maps Mobile SDK for Business

The Google Maps Mobile SDK for Business license provides enhanced capabilities for both the Google Maps SDK for iOS and the Google Maps Android API. If you have purchased a Google Maps Mobile SDK for Business license, please refer to the Google Maps API for Business documentation for additional, supplementary information.

Attribution Requirements

If you use the Google Maps Android API in your application, you must include the Google Play Services attribution text as part of a "Legal Notices" section in your application. Including legal notices as an independent menu item, or as part of an "About" menu item, is recommended.

The attribution text is available by making a call to GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo.

Sample Code

A demo app is bundled with the Google Play services SDK. You can use it for sample code and to view the demo.

The instructions below assume that you are using the Android Developer Tools (ADT) plugin in Eclipse.

First you must add Google Play services as an Android library project as follows:

  1. Select File > Import > Android > Existing Android Code Into Workspace and click Next.
  2. Select Browse, enter <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib, and click Open.
  3. Select Copy projects into workspace and click Finish.
  4. Mark Google Play services as a library: Right-click the google-play-services_lib project, and choose Properties > Android. Tick the Is Library option.

Import the sample project:

  1. Select File > New > Other > Android Sample Project and click Next.
  2. Select the latest version of the Android SDK and click Next.
  3. Scroll down the list of samples and select Maps [Google Play Services]. Click Finish.

Set up dependencies and run the demo app:

  1. Reference the Google Play services library as a dependency for the demo app: Right-click the Maps project and choose Properties > Android. Check that the library section contains a reference to the google-play-services_lib project. If it does not, follow the steps in Referencing a Library Project.
  2. Add your own Google Maps Android API key. The package name for the demo app is com.example.mapdemo. Note that the demo app already includes an API key in its manifest file. You will need to replace the key with your own API key.
  3. If you haven't already done so, enable developer mode on the Android device. Then attach the Android device to your computer. Note that you cannot use the emulator for running Google Maps Android API v2.
  4. Select the Maps project, and choose Run > Run to run the demo app.

Run the app to see a list of available demos that you can run on your own device:

The Google Maps Android API demo app
Google Maps Android API demo app

Authentifizierung erforderlich

Dazu müssen Sie in Google+ angemeldet sein.

Anmeldung...

Google Developers braucht hierfür Ihre Erlaubnis.