mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
Update result of cameraForBounds (#35891)
This commit is contained in:
committed by
Ben Lichtman
parent
653fbb1999
commit
ea62d7c444
9
types/mapbox-gl/index.d.ts
vendored
9
types/mapbox-gl/index.d.ts
vendored
@@ -199,7 +199,7 @@ declare namespace mapboxgl {
|
||||
|
||||
setPitch(pitch: number, eventData?: EventData): this;
|
||||
|
||||
cameraForBounds(bounds: LngLatBoundsLike, options?: CameraForBoundsOptions): CameraOptions | undefined;
|
||||
cameraForBounds(bounds: LngLatBoundsLike, options?: CameraForBoundsOptions): CameraForBoundsResult | undefined;
|
||||
|
||||
fitBounds(bounds: LngLatBoundsLike, options?: mapboxgl.FitBoundsOptions, eventData?: mapboxgl.EventData): this;
|
||||
|
||||
@@ -1211,6 +1211,13 @@ declare namespace mapboxgl {
|
||||
maxZoom?: number;
|
||||
}
|
||||
|
||||
// The Mapbox docs say that if the result is defined, it will have zoom, center and bearing set.
|
||||
// In practice center is always a {lat, lng} object.
|
||||
export type CameraForBoundsResult = Required<Pick<CameraOptions, 'zoom' | 'bearing'>> & {
|
||||
/** Map center */
|
||||
center: {lng: number; lat: number};
|
||||
};
|
||||
|
||||
/**
|
||||
* FlyToOptions
|
||||
*/
|
||||
|
||||
@@ -510,8 +510,8 @@ let cameraForBoundsOpts: mapboxgl.CameraForBoundsOptions = {
|
||||
...cameraOpts,
|
||||
}
|
||||
|
||||
expectType<mapboxgl.CameraOptions | undefined>(map.cameraForBounds(lnglatboundslike));
|
||||
expectType<mapboxgl.CameraOptions | undefined>(map.cameraForBounds(lnglatboundslike, cameraForBoundsOpts));
|
||||
expectType<mapboxgl.CameraForBoundsResult | undefined>(map.cameraForBounds(lnglatboundslike));
|
||||
expectType<mapboxgl.CameraForBoundsResult | undefined>(map.cameraForBounds(lnglatboundslike, cameraForBoundsOpts));
|
||||
|
||||
expectType<mapboxgl.Map>(map.fitScreenCoordinates([0, 0], pointlike, 1));
|
||||
expectType<mapboxgl.Map>(map.fitScreenCoordinates([0, 0], pointlike, 1, cameraOpts));
|
||||
|
||||
Reference in New Issue
Block a user