[Maps] Add max zoom and padding when fitting on bounds (#31016) (#31231)

This commit is contained in:
Thomas Neirynck 2019-02-15 09:06:51 -05:00 committed by GitHub
parent 066ab863f3
commit 3573807ea1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -185,7 +185,9 @@ export class MBMapContainer extends React.Component {
new mapboxgl.LngLat(clamp(goto.bounds.min_lon, -180, 180), clamp(goto.bounds.min_lat, -89, 89)),
new mapboxgl.LngLat(clamp(goto.bounds.max_lon, -180, 180), clamp(goto.bounds.max_lat, -89, 89)),
);
this._mbMap.fitBounds(lnLatBounds);
//maxZoom ensure we're not zooming in too far on single points or small shapes
//the padding is to avoid too tight of a fit around edges
this._mbMap.fitBounds(lnLatBounds, { maxZoom: 17, padding: 16 });
} else if (goto.center) {
this._mbMap.setZoom(goto.center.zoom);
this._mbMap.setCenter({