Open sgrillon14 opened 6 years ago
This worked for me (this makes a big assumption you're using ngx-leaflet and already have it working in your Angular2+ app):
src/typings.d.ts
, the content looks like below (just add more functions as needed):
import * as L from 'leaflet';
declare module 'leaflet' {
export class GeometryUtil {
static computeAngle(a: L.Point, b: L.Point): number;
static closest(map: L.Map, layer: L.Layer, latlng: L.LatLng, vertices?: boolean): L.LatLng;
}
}
npm install leaflet-geometryutil
import 'leaflet-geometryutil'
in some file (component, service, whatever...)const latlng: LatLng = GeometryUtil.closest(this.map, this.polyline, map.getBounds().getCenter())
Angular 2+ uses TypeScript so you need the type definition to use this library. Unfortunately a dedicated type definition for this library doesn't exist yet. But you can still write a minimal
.d.ts
file just for thedestination()
function and import it into your TS project. As an example, you can take a look at this.