mapbox / mapbox/mapbox-maps-flutter
FR: declarative MapWidget
Nobody has claimed this yet.
- Dominant language
- Dart
- Stars
- 380
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
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! 👍
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the MapWidget and MapboxMap entry points, then study the existing declarative viewport implementation mentioned in the issue. Define how scaleBar, compass, locationComponent, styleImages, layers, sources, styleUri, and viewport would be configured and updated declaratively. Done means these values can be supplied as widget parameters and changes react without the described callback and async setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- mobile-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100