Skip to content

Commit

Permalink
Fix display of marker pin swapping WFS layers.
Browse files Browse the repository at this point in the history
If multiple layers are being shown (e.g. Peterborough trees) then the
number of visible layers could go 1 -> 2 -> 3 -> 2, and this code would
get confused and reshow the marker pin even though an asset had been
selected.
  • Loading branch information
dracos committed Aug 18, 2020
1 parent 2f7ce01 commit 80d47db
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions web/cobrands/fixmystreet/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,8 @@ function _update_message(message, c) {
}
}

var lastVisible = 0;

function layer_visibilitychanged() {
if (this.fixmystreet.road) {
if (!this.getVisibility()) {
Expand Down Expand Up @@ -527,12 +529,13 @@ function layer_visibilitychanged() {
visible++;
}
}
if (visible === 2 || visible === 0) {
// We're either switching WFS layers (so going 1->2->1 or 1->0->1)
// or switching off WFS layer (so going 1->0). Either way, we want
// to show the marker again.
if (visible === 0 || visible > lastVisible) {
// We're either switching WFS layers (so going 1->2->1 or 1->0->1 or
// even 1->2->3->2) or switching off WFS layer (so going 1->0).
// Whichever way, we want to show the marker again.
fixmystreet.markers.setVisibility(true);
}
lastVisible = visible;
if (!this.fixmystreet.non_interactive) {
this.select_nearest_asset();
}
Expand Down

0 comments on commit 80d47db

Please sign in to comment.