mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
Add GeometryUtil functions to leaflet-draw (#14755)
* Add GeometryUtil functions to leaflet-draw Add two functions in the GeometryUtil namespace of leaflet-draw * Remove illegal whitespaces * Add GeometryUtil function calls to tests Validate that the function declarations are valid by adding calls of geodesicArea() and readableArea() to the tests. Remove a whitespace that the linter complained about.
This commit is contained in:
committed by
Mohamed Hegazy
parent
c0948a79a2
commit
1636a8e3aa
Vendored
+13
@@ -349,4 +349,17 @@ declare namespace L {
|
||||
handler: string;
|
||||
}
|
||||
}
|
||||
|
||||
namespace GeometryUtil {
|
||||
|
||||
/**
|
||||
* Returns the area of a polygon drawn with leaflet.draw
|
||||
*/
|
||||
export function geodesicArea(coordinates: L.LatLngLiteral[]): number;
|
||||
|
||||
/**
|
||||
* Returns a readable area string in yards or metric
|
||||
*/
|
||||
export function readableArea(area: number, isMetric: boolean): string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,3 +42,7 @@ map.on('draw:created', (e: any) => {
|
||||
|
||||
drawnItems.addLayer(layer);
|
||||
});
|
||||
|
||||
let examplePolygon: L.LatLngLiteral[] = [{lng: 0, lat: 0}, {lng: 10, lat: 0}, {lng: 10, lat: 10}, {lng: 0, lat: 10}, {lng: 0, lat: 0}];
|
||||
let examplePolygonArea: number = L.GeometryUtil.geodesicArea(examplePolygon);
|
||||
L.GeometryUtil.readableArea(examplePolygonArea, true);
|
||||
|
||||
Reference in New Issue
Block a user