Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-leaflet-easyprint

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-leaflet-easyprint

React wrapper of leaflet-easyPrint. A simple leaflet plugin which adds an icon to print or export a map.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
281
increased by3.69%
Maintainers
1
Weekly downloads
 
Created
Source

react-leaflet-easyprint

React wrapper of leaflet-easyPrint for react-leaflet.

A simple leaflet plugin which adds an icon to print or export a map.

Demo.

Demo JSFiddle

Tested with Leaflet 1.3.1 and React-Leaflet 1.8.0

Installation

Install via NPM

npm install react-leaflet-easyprint --save

Usage example

import { Map, TileLayer } from 'react-leaflet';
import PrintControl from 'react-leaflet-easyprint';
		
<Map center={[101.483459, 2.938926]} zoom={12}>
  <TileLayer
    url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
    attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
  />

  <PrintControl ref={(ref) => { this.printControl = ref; }} position="topleft" sizeModes={['Current', 'A4Portrait', 'A4Landscape']} hideControlContainer={false} />
  <PrintControl position="topleft" sizeModes={['Current', 'A4Portrait', 'A4Landscape']} hideControlContainer={false} title="Export as PNG" exportOnly />
</Map>

Options

Any props passed to PrintControl are passed down to leaflet-easyPrint.

Refer leaflet-easyPrint options for a complete list of options supported.

Methods / Using programmatically

Use react ref to call printMap(size, filename) function programmatically. Refer Doc for parameters accepted by printMap().

Example

...

<button onClick={this.printControl.printMap('A4Portrait', 'MyFileName')} >Print Map</button>

...

Credits

Credits goes to rowanwins and all the contributors for the original work.

License

MIT License

Keywords

FAQs

Package last updated on 18 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc