ol-ext icon indicating copy to clipboard operation
ol-ext copied to clipboard

Split interaction not snapping to multiple layers

Open iangthornton opened this issue 6 years ago • 3 comments

I have several layers and yet the snap functionality for the split interaction is only finding features in the first source in my array of sources (this.sources_).

The check to see if the distance to the object, d, is within range happens outside the sources loop, rather than in it:

https://github.com/Viglino/ol-ext/blob/845aea47b441512caf739fab390755982f73027c/src/interaction/Split.js#L162

So the getClosestFeature method will return false because a feature in the first source is too far away, even if there is a closer feature in the next source. This is because of the break on L159.

A better way to do it may be to find the closest feature for each source and then only return false if no layer has a feature within range, or otherwise snap to the closest of those features.

Happy to elaborate if that's not clear enough.

iangthornton avatar May 28 '20 19:05 iangthornton

You're right the break must be removed. All layers have to be checked to get the closests feature....

Viglino avatar May 29 '20 06:05 Viglino

Fixed in the last commit!

Viglino avatar May 29 '20 06:05 Viglino

Thanks @Viglino keep up the good work

iangthornton avatar May 29 '20 16:05 iangthornton