[@types/mapbox-gl] Expose MercatorCoordinate class (#35553)

This commit is contained in:
xibre 2019-05-22 02:58:59 +07:00 committed by Ryan Cavanaugh
parent d625bf3d51
commit a4ca3e967b
2 changed files with 41 additions and 0 deletions

View File

@ -971,6 +971,35 @@ declare namespace mapboxgl {
static convert(a: PointLike): Point;
}
/**
* MercatorCoordinate
*/
export class MercatorCoordinate {
/** The x component of the position. */
x: number;
/** The y component of the position. */
y: number;
/**
* The z component of the position.
*
* @default 0
*/
z?: number;
constructor(x: number, y: number, z?: number);
/** Returns the altitude in meters of the coordinate. */
toAltitude(): number;
/** Returns the LngLat for the coordinate. */
toLngLat(): LngLat;
/** Project a LngLat to a MercatorCoordinate. */
static fromLngLat(lngLatLike: LngLatLike, altitude?: number): MercatorCoordinate;
}
/**
* Marker
*/

View File

@ -407,6 +407,7 @@ attributionControl.on('click', () => {});
declare var lnglat: mapboxgl.LngLat;
declare var lnglatlike: mapboxgl.LngLatLike;
declare var lnglatboundslike: mapboxgl.LngLatBoundsLike;
declare var mercatorcoordinate: mapboxgl.MercatorCoordinate;
declare var pointlike: mapboxgl.PointLike;
function expectType<T>(value: T) { /* let the compiler handle things */ }
@ -460,6 +461,17 @@ expectType<mapboxgl.PointLike>([0, 0]);
new mapboxgl.Point(0, 0);
expectType<mapboxgl.Point>(mapboxgl.Point.convert(pointlike));
/*
* MercatorCoordinate
*/
new mapboxgl.MercatorCoordinate(0, 0);
new mapboxgl.MercatorCoordinate(0, 0, 0);
expectType<number>(mercatorcoordinate.toAltitude());
expectType<mapboxgl.LngLat>(mercatorcoordinate.toLngLat());
expectType<mapboxgl.MercatorCoordinate>(mapboxgl.MercatorCoordinate.fromLngLat(lnglatlike));
expectType<mapboxgl.MercatorCoordinate>(mapboxgl.MercatorCoordinate.fromLngLat(lnglatlike, 0));
/*
* TransformRequestFunction
*/