@davidsouthgate/leaflet-clonelayer
v1.0.8
Published
Clone leaflet layers. Fork of repo https://github.com/jieter/leaflet-clonelayer by Jan Pieter Waagmeester <[email protected]>.
Downloads
5
Readme
Leaflet Clone Layer
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 [email protected]
- Also clones a layer's
options
(including renderers) - Used in jieter/Leaflet.layerscontrol-minimap
Fork of jieter/leaflet-clonelayer by Jan Pieter Waagmeester [email protected].
Installatiom
npm install @davidsouthgate/leaflet-clonelayer
Example
var cloneLayer = require('@davidsouthgate/leaflet-clonelayer');
var layer = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <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.8 (2020-09-30)
- Added support for cloning popups included in a layer
1.0.5 (2018-02-22)
1.0.4 (2017-01-31)
- Drop leaflet 0.7.7 support, use [email protected]
- Also clones a layer's
options
(including renderers)