Clone leaflet layers
Switch branches/tags
Clone or download
Latest commit 8004c52 Aug 24, 2018


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


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

var layer = L.tileLayer('http://{s}{z}/{x}/{y}.png', {
	attribution: '&copy; <a href="">OpenStreetMap</a>'
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


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)