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

[Feat] Optional width and height parameters in Map viewState #2322

Open
StanislavMyakishev opened this issue Nov 22, 2023 · 1 comment
Open
Labels

Comments

@StanislavMyakishev
Copy link

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;
}
@Pessimistress
Copy link
Collaborator

viewState is not documented because you are not supposed to use it. What is your use case that cannot be achieved otherwise?

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

No branches or pull requests

2 participants