New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

leaflet-clonelayer

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-clonelayer

Clone leaflet layers

1.0.7
latest
Source
npm
Version published
Weekly downloads
1.4K
40.86%
Maintainers
1
Weekly downloads
 
Created
Source

leaflet-clonelayer

Leaflet layer instances cannot be added to different maps in one javascript runtime. leaflet-clonelayer clones layers to allow reuse.

  • Works with leaflet 1.0.3, for Leaflet 0.7.7 support use leaflet-clonelayer@1.0.2
  • Also clones a layer's options (including renderers)
  • Used in jieter/Leaflet.layerscontrol-minimap

Example

var cloneLayer = require('leaflet-clonelayer');

var layer = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
	attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map1);
console.log(L.stamp(layer));  // 1

var cloned = cloneLayer(layer);
console.log(L.stamp(cloned));  // 2

// Different _leaflet_id, so now we can safely add it to another map
cloned.addTo(map2);

Changelog

1.0.5 (2018-02-22)

  • Added support for L.TileLayer.WMS #5 by @mhasbie

1.0.4 (2017-01-31)

  • Drop leaflet 0.7.7 support, use leaflet-clonelayer@1.0.2
  • Also clones a layer's options (including renderers)

Keywords

leaflet

FAQs

Package last updated on 24 Aug 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