Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: declarative MapWidget #821

Open
vchrisb opened this issue Dec 20, 2024 · 0 comments
Open

FR: declarative MapWidget #821

vchrisb opened this issue Dec 20, 2024 · 0 comments

Comments

@vchrisb
Copy link

vchrisb commented Dec 20, 2024

While the MapWidget and its MapboxMap have a lot of great features, it is mostly configured imperatively, which isn't Flutter's declarative approach. It is somewhat difficult and complicated to use different callbacks and async waits to configure the MapWidget.

e.g. to set MapboxMap scaleBar settings, I first need to get the MapboxMap in the onMapCreated callback. To load custom icons I then need to use onStyleLoaded and wait the icons to be fully loaded before I can add a SymbolLayer.
So overall this is complicated an error prone.

It would be awesome, if the MapWidget would be fully declarative, similar like the new viewport is implemented.
Something like:

MapWidget(
  key: const ValueKey('mapWidget'),
  scaleBar: ScaleBarSettings(),
  compass: CompassSettings(),
  locationComponent: LocationComponentSettings(),
  styleImages: [styleImage(),styleImage()],
  layers: [SymbolLayer(), LineLayer()],
  sources: [GeoJsonSource()],
  viewport: CameraViewportState(
    center: Position(-117.918976, 33.812092),
    zoom: 18,
  ),
  styleUri: 'mapbox://styles/...',
)

If one of the parameter values change, the MapWidget() will react to it. For viewport it would be great to have a default viewport transition, as updating the center might not be done via setStateWithViewportAnimation, but rather a state management tool like riverpod.

Looking forward to get feedback! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant