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

leaflet-image

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-image

export leaflet maps as images

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.6K
increased by10.63%
Maintainers
1
Weekly downloads
 
Created
Source

leaflet-image

Export images out of Leaflet maps without a server component, by using Canvas and CORS.

Requirements

  • Any tile layer providers (OSM, MapBox, etc) must support CORS
  • Any markers on the map must also support CORS. The default Leaflet-CDN markers don't, so they aren't supported.
  • Your browser must support CORS and Canvas, so IE >= 10 with no exceptions.

usage

browserify

npm install --save leaflet-image

web

curl https://raw.github.com/mapbox/leaflet-image/gh-pages/leaflet-image.js > leaflet-image.js

example

var map = L.mapbox.map('map', 'tmcw.map-u4ca5hnt').setView([38.9, -77.03], 14);
leafletImage(map, function(canvas) {
    // now you have canvas
});

// example thing to do with that canvas
function doImage(err, canvas) {
    var img = document.createElement('img');
    var dimensions = map.getSize();
    img.width = dimensions.x;
    img.height = dimensions.y;
    img.src = canvas.toDataURL();
    document.getElementById('images').innerHTML = '';
    document.getElementById('images').appendChild(img);
}

api

leafletImage(map, callback)

map is a L.map or L.mapbox.map, callback takes (err, canvas).

Keywords

FAQs

Package last updated on 23 Sep 2013

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