├── .gitignore
├── .npmignore
├── CHANGELOG.md
├── LICENSE
├── README.md
├── index.html
├── index.js
├── layout.css
├── leaflet-side-by-side.js
├── leaflet-side-by-side.min.js
├── package.json
├── range-icon.png
├── range.css
└── screencast.gif
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | leaflet-side-by-side.js
2 | leaflet-side-by-side.min.js
3 | screencast.gif
4 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | All notable changes to this project will be documented in this file.
4 | This project adheres to [Semantic Versioning](http://semver.org/).
5 |
6 | ## Unreleased
7 |
8 | - ADDED: Allows Leaflet version 0.7.7 through 1.x
9 |
10 | ## [v2.0.0] - 2015-12-08
11 |
12 | - ADDED: Add `setLeftLayers()` and `setRightLayers()` methods
13 | - ADDED: `options.padding`
14 | - ADDED: `getPosition()` returns the x coordinate (relative to the map container) of the divider
15 | - FIXED: **[BREAKING]** Export factory function on `L.control` not `L.Control`
16 | - FIXED: Slider drag was not working on touch devices
17 |
18 | ## [v1.1.1] - 2015-12-03
19 |
20 | - FIXED: fix package.json settings for npm distribution
21 |
22 | ## [v1.1.0] - 2015-12-03
23 |
24 | - ADDED: Events
25 | - FIXED: Fix initial divider position in Firefox, should start in middle of map
26 |
27 | ## v1.0.2 - 2015-12-02
28 |
29 | Initial release
30 |
31 | [Unreleased]: https://github.com/digidem/leaflet-side-by-side/compare/v2.0.0...HEAD
32 | [Unreleased]: https://github.com/digidem/leaflet-side-by-side/compare/v1.1.1...v2.0.0
33 | [v1.1.1]: https://github.com/digidem/leaflet-side-by-side/compare/v1.1.0...v1.1.1
34 | [v1.1.0]: https://github.com/digidem/leaflet-side-by-side/compare/v1.0.2...v1.1.0
35 |
36 | ## v1.0.3 - 2022-8-22
37 |
38 | Update to support leaflet 1.8
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015 Gregor MacLennan
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a
4 | copy of this software and associated documentation files (the "Software"),
5 | to deal in the Software without restriction, including without limitation
6 | the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 | and/or sell copies of the Software, and to permit persons to whom the
8 | Software is furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in
11 | all copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19 | DEALINGS IN THE SOFTWARE.
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # leaflet-side-by-side
2 |
3 | A Leaflet control to add a split screen to compare two map overlays.
4 |
5 | 
6 |
7 | ### L.control.sideBySide(_leftLayer[s]_, _rightLayer[s]_)
8 |
9 | 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.
10 |
11 | ### Parameters
12 |
13 | | parameter | type | description |
14 | | ---------- | -------------- | ------------- |
15 | | `leftLayers` | L.Layer\|array | A Leaflet Layer or array of layers to show on the left side of the map. Any layer added to the map that is in this array will be shown on the left |
16 | | `rightLayers` | L.Layer\|array | A Leaflet Layer or array of layers to show on the right side of the map. Any layer added to the map that is in this array will be shown on the right. These *should not be* the same as any layers in `leftLayers` |
17 | | `options` | Object | Options |
18 | | `options.padding` | Number | Padding between slider min/max and the edge of the screen in pixels. Defaults to `44` - the width of the slider thumb |
19 |
20 | ### Events
21 |
22 | Subscribe to events using [these methods](http://leafletjs.com/reference.html#events)
23 |
24 | | Event | Data | Description |
25 | | ---------- | -------------- | ------------- |
26 | | `leftlayeradd` | [LayerEvent](http://leafletjs.com/reference.html#layer-event) | Fired when a layer is added to the left-hand-side pane |
27 | | `leftlayerremove` | [LayerEvent](http://leafletjs.com/reference.html#layer-event) | Fired when a layer is removed from the left-hand-side pane |
28 | | `rightlayeradd` | [LayerEvent](http://leafletjs.com/reference.html#layer-event) | Fired when a layer is added to the right-hand-side pane |
29 | | `rightlayerremove` | [LayerEvent](http://leafletjs.com/reference.html#layer-event) | You guessed it... fired when a layer is removed from the right-hand-side pane |
30 | | `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. |
31 |
32 | ### Methods
33 |
34 | | Method | Returns | Description |
35 | | ---------- | -------------- | ------------- |
36 | | `setLeftLayers` | `this` | Set the layer(s) for the left side |
37 | | `setRightLayers` | `this` | Set the layer(s) for the right side |
38 |
39 | ### Usage
40 |
41 | Add the script to the top of your page (css is included in the javascript):
42 |
43 | ```html
44 |
45 | ```
46 |
47 | Or if you are using browserify:
48 |
49 | ```js
50 | var sideBySide = require('leaflet-side-by-side')
51 | ```
52 |
53 | Then create a map, add two layers to it, and create the SideBySide control and add it to the map:
54 |
55 | ```js
56 | var map = L.map('map').setView([51.505, -0.09], 13);
57 |
58 | var myLayer1 = L.tileLayer(...).addTo(map);
59 |
60 | var myLayer2 = L.tileLayer(...).addTo(map)
61 |
62 | L.control.sideBySide(myLayer1, myLayer2).addTo(map);
63 | ```
64 |
65 | ### Example
66 |
67 | [Live Example](http://lab.digital-democracy.org/leaflet-side-by-side/) see [source](index.html)
68 |
69 | ### Limitations
70 |
71 | - The divider is not movable with IE.
72 | - Probably won't work in IE8, but what does?
73 |
74 | ### License
75 |
76 | MIT
77 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |