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:
Mike van Afferden
2017-03-10 15:59:32 -08:00
committed by Mohamed Hegazy
parent c0948a79a2
commit 1636a8e3aa
2 changed files with 17 additions and 0 deletions
+13
View File
@@ -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;
}
}
+4
View File
@@ -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);