I have used an adjusted version of the shared views example from openlayers.org: https://openlayers.org/en/latest/examples/side-by-side.html
var layer = new TileLayer({
source: new OSM()
});
window['view1'] = new ol.View({
center: [0, 0],
zoom: 1
});
window['view2'] = new ol.View({
center: [0, 0],
zoom: 1
});
window['map1'] = new ol.Map ({
target: 'map1',
layers: [layer],
view: window['view1']
});
window['map2'] = new ol.Map({
target: 'map2',
layers: [layer],
view: window['view2']
});
window['map1'].addEventListener('change:resolution', function
(evt) {
window['view1'] = window['view2'];
window['map1'].setView(window['view1']);
}, false);
window['map2'].addEventListener('change:resolution', function
(evt) {
window['view2'] = window['view1'];
window['map2'].setView(window['view2']);
}, false);
How do I properly unbind these 'new' equal views afterwards? (probably the answer is very simple, but it has given me headaches right now)
P.S: I use the global variable (e.g. window['map2']) because I need to be able to bind and unbind multiple Maps.