Reputation: 8054
Here I am trying to achieve centering a MapBox
map in a given area:
From what I know from its documentation, MapBox
only allows centering in a single centerCoordinate
and setting zoomLevel
. By setting zoomLevel
there seems to be no guarantee that the rectangle will be contained inside the MapBox
.
How to achieve a whole area being displayed at once and the map being centered around it?
<Mapbox
accessToken={'ACCESS_TOKEN'}
centerCoordinate={this.state.currentView.coordinates}
zoomLevel={this.state.currentView.zoomLevel}
/>
Upvotes: 0
Views: 638
Reputation: 3802
The Map#fitBounds
method seems to do exactly what you're looking for. I'm not sure if / how to use it with the react wrapper, however.
Upvotes: 2