MelihAltintas / vue3-openlayers

Web map Vue 3.x components with the power of OpenLayers
https://vue3openlayers.netlify.app/
MIT License
671 stars 125 forks source link

Swipe Control layer position control #376

Open randydapogi opened 3 weeks ago

randydapogi commented 3 weeks ago

Hello. How do we control in which side of the Swipe Control the layer renders when layer is added to layerList. From my observation when adding multiple layers in layerList, the odd index layer are rendered in the left while the even index layers are rendered in the right. Is there a way to control the position of the layer similar to ctrl.addLayer(osm, true) of the ol-ext where passing true renders the layer to the right while not passing a parameter default renders the layer to the left?

d-koppenhagen commented 2 weeks ago

currently it's implemented like this:

props.layerList?.forEach((layer, index) => {
  control.value.addLayer(layer, index === 1);
});

Which means, that the second passed layer is always added to the right, others to the left.

d-koppenhagen commented 2 weeks ago

Original implementation from ol-ext:

https://github.com/Viglino/ol-ext/blob/master/src/control/Swipe.js#L43-L46

This would be more explicit but changing it to align the API would introduce also a breaking change.