Gregor MacLennan 30a9a4be24 blacklist instead of whitelist files for npm | il y a 9 ans | |
---|---|---|
.npmignore | il y a 9 ans | |
CHANGELOG.md | il y a 9 ans | |
LICENSE | il y a 9 ans | |
README.md | il y a 9 ans | |
index.html | il y a 9 ans | |
index.js | il y a 9 ans | |
layout.css | il y a 9 ans | |
leaflet-side-by-side.js | il y a 9 ans | |
leaflet-side-by-side.min.js | il y a 9 ans | |
package.json | il y a 9 ans | |
range-icon.png | il y a 9 ans | |
range.css | il y a 9 ans | |
screencast.gif | il y a 9 ans |
A Leaflet control to add a split screen to compare two map overlays.
Creates a new Leaflet Control for comparing two layers or collections of layers. It does not add the layers to the map - you need to do that manually. Extends L.Control
but setPosition()
and getPosition
are noop
because the position is always the same - it does not make sense for this control to be in the corner like other Leaflet controls.
parameter | type | description |
---|---|---|
leftLayers |
L.Layer|array | A Leaflet Layer or array of layers to show on the left side of the map. Any layers in this array that are added to the map will be shown on the left |
rightLayers |
L.Layer|array | A Leaflet Layer or array of layers to show on the right side of the map. Any layers in this array that are added to the map will be shown on the right. These should not be the same as any layers in leftLayers |
Subscribe to events using these methods
Event | Data | Description |
---|---|---|
leftlayeradd |
LayerEvent | Fired when a layer is added to the left-hand-side pane |
leftlayerremove |
LayerEvent | Fired when a layer is removed from the left-hand-side pane |
rightlayeradd |
LayerEvent | Fired when a layer is added to the right-hand-side pane |
rightlayerremove |
LayerEvent | You guessed it… fired when a layer is removed from the right-hand-side pane |
dividermove |
{x: Number} | Fired when the divider is moved. Returns an event object with the property x = the pixels of the divider from the left side of the map container. |
Add the script to the top of your page (css is included in the javascript):
<script src="leaflet-side-by-side.js"></script>
Or if you are using browserify:
var sideBySide = require('leaflet-side-by-side')
Then create a map, add two layers to it, and create the SideBySide control and add it to the map:
var map = L.map('map').setView([51.505, -0.09], 13);
var myLayer1 = L.tileLayer(...).addTo(map);
var myLayer2 = L.tileLayer(...).addTo(map)
L.Control.sideBySide(myLayer1, myLayer2).addTo(map);
Live Example see source
MIT