0Pricing
Android Academy · Lesson

Markers and Camera

Place markers and move the camera.

Marking the Map

A blank map is just tiles. Markers turn it into information — a pin for a shop, a restaurant, the user's destination. And the camera moves the viewport to wherever the story needs.

In this lesson you'll add markers, customize them, group them in clusters, and animate the camera smoothly between places.

Adding a Marker

In maps-compose, markers are composables you place inside the GoogleMap content lambda. Each Marker takes a MarkerState holding its position.

import com.google.maps.android.compose.Marker
import com.google.maps.android.compose.rememberMarkerState

@Composable
fun MapWithMarker() {
    val position = LatLng(37.7749, -122.4194)
    GoogleMap(modifier = Modifier.fillMaxSize()) {
        Marker(
            state = rememberMarkerState(position = position),
            title = "San Francisco",
            snippet = "Welcome to SF"
        )
    }
}

All lessons in this course

  1. Showing a Map
  2. Getting the User Location
  3. Markers and Camera
  4. Location Permissions Done Right
← Back to Android Academy