Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swipe Control layer position control #376

Open
randydapogi opened this issue Aug 23, 2024 · 2 comments
Open

Swipe Control layer position control #376

randydapogi opened this issue Aug 23, 2024 · 2 comments

Comments

@randydapogi
Copy link

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
Copy link
Collaborator

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
Copy link
Collaborator

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.

d-koppenhagen added a commit that referenced this issue Sep 4, 2024
Before, only the second passed layer was added to the right side. Now you can explicitly pass (multiple) layers for the left (or top) using `layers` and for the right (bottom) using `rightLayers`.

BREAKING CHANGE: `ol-swipe-control`: property `layerList` has been removed and splitted into `layers` and `rightLayers`. Please pass explicitly `layers` for the left side (or top, depending on the `orientation`) and `rightLayers` for the right side (or bottom, depending on the `orientation`)
Closes: #376
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants