lc

leaflet-clonelayer

Clone leaflet layers

Showing:

Popularity

Downloads/wk

478

GitHub Stars

22

Maintenance

Last Commit

4mos ago

Contributors

5

Package

Dependencies

0

Size (min+gzip)

0.6KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

leaflet-clonelayer

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

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)

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100