Skip to content

consider decoupling the map lifecycle from the map view #550

@sargunv

Description

@sargunv

Feature Description

Currently, if you remove and reinsert the composable containing a map, the map will be destroyed and reinitialized, and there's nothing the user can do to retain it. With the Android and iOS SDKs, that's necessary, because the map is tied to its View, which is owned by the composable.

It's hard to reason about a composable's life cycle, and composables should be designed to be cheap to reinitialize. So in an ideal world, it should be possible for the user to take control of the map lifecycle, for example retaining it in a ViewModel or a Compose 1.10 retain block regardless of whether it's displayed in the UI at the moment. And have it be cheap to attach an already initialized map to the UI. This will enable easier testing and a more predictable map life cycle.

With native core integration, we control the renderer frontend ourselves, and so have the opportunity to decouple the map from the surface it renders to. Unsure if this is possible with MapLibre JS; can we detach and re-attach a Canvas from the map?

Prerequisites:

  • complete native core integration for desktop, Android, and iOS
  • investigate how such a change would affect web

Metadata

Metadata

Assignees

No one assigned

    Labels

    api ergonomicsImproves API usability without net-new functionalityblockedThe issue or PR is blocked by another issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions