Use leaflet-easyPrint in Typescript app
See original GitHub issueI tried to import the plugin into a Typescript app and also added the code into the typings file to extend L.control from leaflet but got Uncaught TypeError: L.control.easyPrint is not a function
error.
This is the code from typings file:
import 'leaflet';
declare module 'leaflet' {
namespace Map {
export interface MapOptions {
easyPrintControl? : boolean;
}
}
export interface ControlStatic {
EasyPrint: Control.EasyPrintStatic;
}
namespace Control {
export interface EasyPrintStatic {
new (options?: IEasyPrintConstructorOptions): EasyPrint;
}
export interface IEasyPrintConstructorOptions {
title: string;
position: string;
}
export interface EasyPrint extends L.Control {
}
}
export namespace control {
export function easyPrint (options?: Control.IEasyPrintConstructorOptions): Control.EasyPrint;
}
}
For some reason, my IDE interpretor accepts easyPrint function on L.control but my browser throws the error…
Not really sure where to go from here to be able to use the plugin
Issue Analytics
- State:
- Created 5 years ago
- Comments:17 (2 by maintainers)
Top Results From Across the Web
Using leaflet-easyPrint with Typescript app
I can make it work. I did this: In my typings.d.ts // Import Leaflet into L in case you want to reference Leaflet...
Read more >leaflet-easyprint
A simple leaflet plugin which adds an icon to print or export a map. Features. Supports resizing to prefined sizes (A4 Landscape &...
Read more >react-leaflet-easyprint - npm package
React wrapper of leaflet-easyPrint. A simple leaflet plugin which adds an icon to print or export a map. Visit Snyk Advisor to see...
Read more >Adding print/download option for react leaflet maps - YouTube
This video explains how to print / download a leaflet map in react.Demo + Source :https://react-component-depot.netlify. app / leaflet / print - ...
Read more >leaflet-easyprint examples
Learn how to use leaflet-easyprint by viewing and forking leaflet-easyprint example apps on CodeSandbox.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, I think you can use easyPrint like this : First install easyPrint with npm npm install leaflet-easyprint --save
Then, use it in your typescript file.
@ialixandroae
And you should see the easyPrint control the the map
Hi @jlaverdure-talis ,
Unfortunatelly no and I haven’t tried since. At the moment I’m not sure if this is something in the core of the library or something with my Typescript configuration (something wrong or missing?)