[mapbox-gl] add LngLat.distanceTo (#43084)

This commit is contained in:
Dmytro Gokun 2020-03-14 03:32:08 +02:00 committed by GitHub
parent 8193cd43a0
commit cdc9c593eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -1056,6 +1056,10 @@ declare namespace mapboxgl {
/** Return a LngLat as a string */
toString(): string;
/** Returns the approximate distance between a pair of coordinates in meters
* Uses the Haversine Formula (from R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159) */
distanceTo(lngLat: LngLat): number;
toBounds(radius: number): LngLatBounds;
static convert(input: LngLatLike): mapboxgl.LngLat;

View File

@ -687,6 +687,7 @@ expectType<mapboxgl.LngLatLike>({ lon: 0, lat: 0 });
new mapboxgl.LngLat(0, 0);
expectType<mapboxgl.LngLat>(mapboxgl.LngLat.convert(lnglatlike));
expectType<number>(new mapboxgl.LngLat(0, 0).distanceTo(new mapboxgl.LngLat(0, 0)));
/*
* LngLatBoundsLike