Search code examples
mapsopenlayers

OpenLayers - Share the view with 2 different layers


I would like to share my view with 2 different map:

  1. On the left side the view of my map number 1 (raster or shapefile)
  2. On the right side the view of my map number 2 (raster or shapefile)
  3. For separation, 1 cursor that I can drag and drop to change the location of the separation without changing the view of the 2 maps.

I checked on OpenLayers and the closed I found is that: https://openlayers.org/en/latest/examples/side-by-side.html (but the view of the 2 maps change when the user drag and drop).

I found that link (at 1min27s): https://www.youtube.com/watch?v=xKON7YWWXUI. Is it possible to do that with OpenLayers ? Can we share 1 view into 2 different layers ?


Solution

  • ol-ext lib provides a swipe control.
    See example online: https://viglino.github.io/ol-ext/examples/control/map.control.swipe.html