`layersAdded` is a leftover from `updateLayers` logic before #5474, when there was a single loop that both added and removed layers. Now there are two loops, the first one is removing layers, while the second one is adding, but it can only add one layer.
Before this PR: - the second loop checks the layer code - if it matches, the layer is added and its code is recorded into `layersAdded` - on the final iteration if there's no match, `layersAdded` is checked - if it's empty, layer[0] is added After: - the second loop checks the layer code match OR if it's the final iteration * - if the condition is true, the layer is added and the function returns because there's nothing else to do \* I'm checking `i == 0` inside the loop instead of adding layer[0] after the loop to allow the function to work with empty base layer set. Maybe that's going to be useful for someone. You can view, comment on, or merge this pull request online at: https://github.com/openstreetmap/openstreetmap-website/pull/5560 -- Commit Summary -- * Remove layersAdded variable from map.updateLayers() -- File Changes -- M app/assets/javascripts/leaflet.map.js (9) -- Patch Links -- https://github.com/openstreetmap/openstreetmap-website/pull/5560.patch https://github.com/openstreetmap/openstreetmap-website/pull/5560.diff -- Reply to this email directly or view it on GitHub: https://github.com/openstreetmap/openstreetmap-website/pull/5560 You are receiving this because you are subscribed to this thread. Message ID: <openstreetmap/openstreetmap-website/pull/5...@github.com>
_______________________________________________ rails-dev mailing list rails-dev@openstreetmap.org https://lists.openstreetmap.org/listinfo/rails-dev