![Basic map centered near Sydney in Australia.](https://developers.google.com/static/maps/documentation/android-sdk/examples/images/basic-map.png)

This example creates a map using a `SupportMapFragment` from the
Maps SDK for Android.

For more information, see [Add a map to your Android app](https://developers.google.com/maps/documentation/android-sdk/map.md.txt).

## Get started

Before you can try the sample code, you must configure your development
environment. For more information, see
[Maps SDK for Android code samples](https://developers.google.com/maps/documentation/android-sdk/examples.md.txt).

## View the code


### Kotlin

```kotlin
class BasicMapDemoActivity :
    SamplesBaseActivity(),
    OnMapReadyCallback {

    val SYDNEY = LatLng(-33.862, 151.21)
    val ZOOM_LEVEL = 13f

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.basic_demo)
        val mapFragment: SupportMapFragment? =
            supportFragmentManager.findFragmentById(R.id.map) as? SupportMapFragment
        mapFragment?.getMapAsync(this)
    }

    /**
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just move the camera to Sydney and add a marker in Sydney.
     */
    override fun onMapReady(googleMap: GoogleMap) {
        with(googleMap) {
            moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, ZOOM_LEVEL))
            addMarker(MarkerOptions().position(SYDNEY).title("Sydney"))
        }
    }
}

      
```

### Java

```java
public class BasicMapDemoActivity extends SamplesBaseActivity implements OnMapReadyCallback {

    private static final LatLng SYDNEY = new LatLng(-33.862, 151.21);
    private static final float ZOOM_LEVEL = 13.0f;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(com.example.common_ui.R.layout.basic_demo);

        SupportMapFragment mapFragment =
                (SupportMapFragment)
                        getSupportFragmentManager()
                                .findFragmentById(com.example.common_ui.R.id.map);
        mapFragment.getMapAsync(this);
        applyInsets(findViewById(com.example.common_ui.R.id.map_container));
    }

    /**
     * This is where we can add markers or lines, add listeners or move the camera. In this case, we
     * move the camera to Sydney and add a marker at Sydney.
     */
    @Override
    public void onMapReady(GoogleMap map) {
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(SYDNEY, ZOOM_LEVEL));
        map.addMarker(new MarkerOptions().position(SYDNEY).title("Sydney"));
    }
}

      
```

<br />

## Clone and run the samples

Git is required to run this sample locally. The following command clones the sample
application repository.

```
git clone git@github.com:googlemaps-samples/android-samples.git
```

Import the sample project into Android Studio:

1. In Android Studio, select **File \> New \> Import Project**.
2. Go to the location where you saved the repository and select the project directory for
   Kotlin or Java:

   - **Kotlin** : `PATH-REPO/android-samples/ApiDemos/kotlin`
   - **Java** : `PATH-REPO/android-samples/ApiDemos/java`
3. Select **Open**. Android Studio builds your project, using the Gradle build tool.
4. Create a blank `secrets.properties` file in the same directory as your project's `local.properties` file. For more information about this file, see [Add your API key to the project](https://developers.google.com/maps/documentation/android-sdk/config.md.txt#step_3_add_your_api_key_to_the_project).
5. [Get an API key](https://developers.google.com/maps/documentation/android-sdk/get-api-key.md.txt) from your project with the [Maps SDK for Android enabled](https://developers.google.com/maps/documentation/android-sdk/cloud-setup#enabling-apis).
6. Add the following string to `secrets.properties`, replacing **YOUR_API_KEY** with the value of
   your API key:

   ```
   MAPS_API_KEY=YOUR_API_KEY
   ```
7. Run the app.