Skip to content

Need to be able to determine map bounds from current camera position #143

@spiral123

Description

@spiral123

I have a need to automate the zoom level and position of the Camera on my Google map in order to accurately place it.

In Google Maps Compose I would use something similar to:

val cameraPositionState = rememberCameraPositionState()

// Use a DerivedState to avoid unnecessary recompositions
val mapBounds by remember {
    derivedStateOf {
        cameraPositionState.projection?.visibleRegion?.latLngBounds
    }
}

GoogleMap(
    modifier = Modifier.fillMaxSize(),
    cameraPositionState = cameraPositionState
) {
    // Map content here
}

// Accessing the corners
mapBounds?.let { bounds ->
    val northEast = bounds.northeast
    val southWest = bounds.southwest
}

Do you have any plans to expand your current CameraPosition parameter to support this - or possible add a Google-only variant for CameraPosition?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions