Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jieter/leaflet-clonelayer
Clone leaflet layers
https://github.com/jieter/leaflet-clonelayer
Last synced: 16 days ago
JSON representation
Clone leaflet layers
- Host: GitHub
- URL: https://github.com/jieter/leaflet-clonelayer
- Owner: jieter
- Created: 2015-03-12T10:24:35.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2021-05-20T17:15:49.000Z (over 3 years ago)
- Last Synced: 2024-10-12T06:46:49.995Z (about 1 month ago)
- Language: JavaScript
- Size: 26.4 KB
- Stars: 25
- Watchers: 5
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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 [email protected]
- Also clones a layer's `options` (including renderers)
- Used in [jieter/Leaflet.layerscontrol-minimap](https://github.com/jieter/Leaflet.layerscontrol-minimap)## Example
```JavaScript
var cloneLayer = require('leaflet-clonelayer');var layer = L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap'
}).addTo(map1);
console.log(L.stamp(layer)); // 1var 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](https://github.com/jieter/leaflet-clonelayer/pull/5) by [@mhasbie](https://github.com/mhasbie)### 1.0.4 (2017-01-31)
- Drop leaflet 0.7.7 support, use [email protected]
- Also clones a layer's `options` (including renderers)