Igor-Vladyka / leaflet.browser.print

A leaflet plugin which allows users to print the map directly from the browser
https://igor-vladyka.github.io/leaflet.browser.print/
MIT License
154 stars 76 forks source link

work with React + TypeScript #116

Open KonstantinBiryukov opened 2 years ago

KonstantinBiryukov commented 2 years ago

I am curious if it is supposed to work in React + TypeScript? After the package is installed. I am trying to do import import "leaflet.browser.print/dist/leaflet.browser.print" Is there anything specific that has to be done to use this library with React + TS?

If I just install the package without any import and write var browserControl = L.control.browserPrint({position: 'topLeft'}).addTo(instance), where instance is a Map object it doesn't work. I have an error: Property 'browserPrint' does not exist on type 'typeof control'. TS2339

And if I suppress this error, I have TypeError: Cannot read properties of undefined (reading 'Mode') How to extend this L.control class by the plugin and use it in React + TS?

doktr commented 1 year ago

@KonstantinBiryukov There is a good tutorial available for the angular module ngx-leaflet. I guess that can be easily adapted for react

https://github.com/bluehalo/ngx-leaflet-tutorial-plugins/tree/master/Leaflet.BrowserPrint