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

Attribution for multiple WMSTile layers not showing correctly on first load #568

Open
3 of 6 tasks
grgurev opened this issue Apr 18, 2020 · 2 comments
Open
3 of 6 tasks
Labels
bug confirmed Issue is accepted as either a bug or a valid enhancement

Comments

@grgurev
Copy link

grgurev commented Apr 18, 2020

Description

When drawing map with multiple WMSTile layers on initial load all three attributions (for each separate WMS layer) are printed as attribution. After first change everything is as should be and attributions are correctly displayed.

Live Demo

https://codesandbox.io/s/eager-feather-vf691

Steps to Reproduce

Create two or more separate WMS layers with different attribution and on initial load all three attributions will be showed.

Expected Results

On initial load only attribution of selected WMS base layer should be displayed as attribution.

Actual Results

On initial load all three attributions are showed and only after first change the attribution is correctly displayed.

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • Safari 9
  • Safari 8
  • IE 11

Versions

  • Leaflet: v1.6.0
  • Vue: v2.6.10
  • Vue2Leaflet: v2.5.2
@DonNicoJs DonNicoJs added the confirmed Issue is accepted as either a bug or a valid enhancement label Apr 19, 2020
@DonNicoJs
Copy link
Member

@grgurev Thanks for opening the issue! Labeled as confirmed

@DonNicoJs DonNicoJs added the bug label Apr 26, 2020
@mikeu
Copy link
Contributor

mikeu commented Aug 19, 2020

As far as I can tell, this is the behaviour in vanilla Leaflet as well, if all of the base layers are added to the map as well as the layers control: https://codesandbox.io/s/leaflet-three-visible-baselayers-gnvte

A simple resolution in the Vue2Leaflet case is to set visible: false on all of the base layers except one, which will then be the only one whose attribution is initially displayed: https://codesandbox.io/s/objective-darkness-g6n0l?file=/App.vue

@DonNicoJs do you think there might still be an issue around how the LControlLayers component works in this situation, or shall we close this? The Leaflet docs do say that "when using multiple base layers, only one of them should be added to the map at instantiation, but all of them should be present in the base layers object when creating the layers control".

So perhaps there's an argument that the logic in LMap.addLayer should attempt to automatically add only the first (visible) base layer to the map, and add all subsequent base layers to only the layers control, then let it take care of handling which layer is added to the map at any given time. But since setting visible on each layer gives the user a straightforward way to determine the initial configuration explicitly, I don't know whether that would be useful behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug confirmed Issue is accepted as either a bug or a valid enhancement
Projects
None yet
Development

No branches or pull requests

3 participants