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

Measure behavior on multiple layers #84

Open
mstenta opened this issue Jul 15, 2020 · 2 comments
Open

Measure behavior on multiple layers #84

mstenta opened this issue Jul 15, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@mstenta
Copy link
Member

mstenta commented Jul 15, 2020

If you try to add the measure behavior to multiple layers (eg: in the "current location" and "new location" layers in the animal move quick form map: https://www.drupal.org/project/farm/issues/3156713), it works at first (both layers show their measurements), but if you then try to edit a layer then the other one disappears.

@mstenta mstenta added the bug Something isn't working label Jul 15, 2020
@jgaehring jgaehring mentioned this issue Jul 15, 2020
5 tasks
@mstenta
Copy link
Member Author

mstenta commented Jul 16, 2020

Dug into this, and it basically comes down to: there is only one layer variable defined in the measure.js behavior code:

So whenever addBehavior('measure', { layer }); runs, it replaces the layer that the behavior is looking at:

({ layer } = options);

Then, specifically, whenever stopMeasure() runs, it goes through and removes any measure overlays with IDs that are not found in the layer. So because layer gets overridden, it doesn't find any of the measures in the first layer, and removes them all:

// Remove the overlay.

@mstenta
Copy link
Member Author

mstenta commented Jul 16, 2020

Similarly, I don't think the measure behavior would work with multiple maps, for the same reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

1 participant