Using Leaflet.PolylineMeasure on Angular

357 Views Asked by At

I'm trying to use this plugin called Leaflet.PolylineMeasure and integrate it into my application. The only issue is that the plugin is in JavaScript while my application is in Angular..

I saw that you can npm install the library: https://www.npmjs.com/package/leaflet.polylinemeasure but I'm not sure how to use it after that. I tried doing L.control.polylineMeasure, but it says Property 'polylineMeasure' does not exist on type 'typeof control'. Most likely because L doesn't have the polylineMeasure function in there.

I am using ngx-leaflet to run leaflet on my application. How can I get it to work on my angular app?

1

There are 1 best solutions below

0
ghybs On

Luckily you have type definitions available for this Leaflet plugin: https://www.npmjs.com/package/@types/leaflet.polylinemeasure

Therefore you just install them in your TypeScript / Angular project: npm install --save-dev @types/leaflet.polylinemeasure

Make sure you import the plugin alongside Leaflet, and the TypeScript compiler should now be happy.