Geographic Information Systems Asked by Sashini Hettiarachchi on May 25, 2021
I want to print a leaflet map in PDF/Image formats and It will be contained,
I’m using a leaflet map with React Typescript. Related versions are,
I tried https://leafletjs.com/plugins.html#printexport leaflet-easyprint and leaflet.browser.print but didn’t get a promising result.
import { Map, withLeaflet} from "react-leaflet"; import PrintControlDefault from 'react-leaflet-easyprint'; const PrintControl = withLeaflet(PrintControlDefault as any); <Map> <PrintControl ref={printMapRef} position="topleft" sizeModes={['Current', 'A4Portrait', 'A4Landscape']} hideControlContainer={false} /> </Map>
Typescript Error:
Type ‘{ ref: MutableRefObject; position: string; sizeModes: string[]; hideControlContainer: boolean; }’ is not assignable to type ‘IntrinsicAttributes & Omit<ContextProps, "leaflet"> & { children?: ReactNode; }’.
Property ‘ref’ does not exist on type ‘IntrinsicAttributes & Omit<ContextProps, "leaflet"> & { children?: ReactNode; }’.
importLfrom"leaflet"; import { useLeaflet } from"react-leaflet"; const { map } = useLeaflet(); (L as any).control.browserPrint({ position:'topright' }).addTo(map);
This works fine, but cannot print WMS layers.
Does anyone have an idea about any plugin or library which is match with above-mentioned conditions?
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP