[Feat] Optional width and height parameters in Map viewState
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 8.5k
- Forks
- 1.4k
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 3
Description
Target Use Case
Map's view state is exposed as a prop for external source to control. But now the viewState is not described in the docs.
If the use case does not require the map to be resized once it's mounted, it is makes it harder to manipulate the view state as we are obliged to provide the container size dimensions as width and height are mandatory.
Proposal
It would be great to have a way to control the map's view state without the need to provide the container size dimensions.
Mention of the viewState prop in the API reference would also be nice.
_updateSize would probably would look somewhat like
_updateSize(nextProps: MapboxProps<StyleT>): boolean {
const { viewState } = nextProps;
if (viewState) {
const map = this._map;
const isWidthUpdated = 'width' in viewState && viewState.width !== map.transform.width;
const isHeightUpdated = 'height' in viewState && viewState.height !== map.transform.height;
if (isWidthUpdated || isHeightUpdated) {
map.resize();
return true;
}
}
return false;
}
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 in src/mapbox/mapbox.ts, following the viewState prop and _updateSize path described in the issue. Confirm the current viewState typing and sizing behavior, then verify that width and height are optional when controlling view state and that the API reference documents the prop.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- data-visualization, documentation, frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100