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

Modifying the results of map.getStyle() modifies the style #4481

Closed
gavinr-maps opened this issue Jul 31, 2024 · 1 comment · Fixed by #4488
Closed

Modifying the results of map.getStyle() modifies the style #4481

gavinr-maps opened this issue Jul 31, 2024 · 1 comment · Fixed by #4488
Labels
bug Something isn't working PR is more than welcomed Extra attention is needed

Comments

@gavinr-maps
Copy link
Contributor

gavinr-maps commented Jul 31, 2024

maplibre-gl-js version: 3.0.0 and higher.

browser: all

Steps to Trigger Behavior

  1. Call map.getStyle() and assign it to a variable.
  2. Modify that variable in some way.
    • Expected: modifying that variable should not change style. Only calling map.setStyle() should do that.
    • Actual: modifying that variable does change style.

Link to Demonstration

  1. Open https://jsbin.com/zeyusuf/4/edit?html,output , which is using [email protected]. Note that even though I'm modifying the variable like this:

      const newStyle = map.getStyle();
      
      newStyle.layers[0].paint = {
        "fill-color": '#AAAAAA',
      };

    ... calling map.getStyle() after I make that change still returns the original value. This is the correct behavior because I have not called map.setStyle().

  2. Open https://jsbin.com/zeyusuf/6/edit?html,output , which is using [email protected] but otherwise the exact some code as above.

    • Expected: calling map.getStyle() after the variable is changed still returns the original value.
    • Actual: calling map.getStyle() after the variable is changed does not return the original value ❌.

Note

@HarelM
Copy link
Collaborator

HarelM commented Jul 31, 2024

Feel free to submit a PR to fix this.
Cc: @zhangyiatmicrosoft.

@HarelM HarelM added bug Something isn't working PR is more than welcomed Extra attention is needed labels Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR is more than welcomed Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants