Sample Code

Select platform: Android iOS JavaScript

The Google Maps repo on GitHub includes a number of samples illustrating the use of the Maps SDK for Android in your Android app. In addition, you can find code snippets on each page of this developer's guide.

Sample map activities on GitHub

The ApiDemos repo on GitHub contains a sample app, including a number of activities that illustrate common usages of the API. You can import and build the app, view the demo and use the sample code supplied as a starting-point for your app.

When you run the sample app, it displays a list of available demos that you can run on your own device. Select one of the options. For example, click Basic Map.

Troubleshooting: If the sample app runs successfully but you don’t see a map, check that you’ve added your API key to the app's manifest file, as described in the signup guide.

Sample app for maps on Wear OS

A sample app is available on GitHub, which you can use as a starting point when building a wearable app. The sample shows you how to set up a basic Google Map on Wear OS.

Code snippets in the developer's guide

Each page in the developer's guide includes code snippets illustrating a particular feature of the API. For example, see the guides for map objects, markers, shapes, and other pages in this guide.