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

When creating Symbols the pathOptions argument is not shallow copied #116

Open
jules43 opened this issue Jun 16, 2024 · 0 comments
Open

Comments

@jules43
Copy link

jules43 commented Jun 16, 2024

If you create two Symbol instances like this:

options.stroke = true;
symbol1 = L.Symbol.arrowHead({pixelSize:10, headAngle: 60, pathOptions: options});
options.stroke = false
symbol2 = L.Symbol.arrowHead({pixelSize:10, headAngle: 60, pathOptions: options});

The first symbol will have it's stroke flag overwritten, so when the object refreshes (say on zoom), it will be created differently. This is due to the setOptions only doing a shallow copy.

To work around this I just change my call to:
symbol1 = L.Symbol.arrowHead({pixelSize:10, headAngle: 60, pathOptions: {...options}});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant