Skip to content

Commit

Permalink
Fix duplicate layer bug
Browse files Browse the repository at this point in the history
  • Loading branch information
giswqs committed Sep 17, 2023
1 parent 8d01510 commit 55b2b6f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions pages/01_morocco.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def change_dataset(change):

def change_image(change):
if change.new:
mosaic = f'{url}/datasets/{dataset.value}/{image.value}.json'
m.add_stac_layer(mosaic, name=image.value, fit_bounds=m.zoom_to_layer)
if change.new not in m.get_layer_names():
mosaic = f'{url}/datasets/{dataset.value}/{image.value}.json'
m.add_stac_layer(mosaic, name=image.value, fit_bounds=m.zoom_to_layer)

image.observe(change_image, names='value')

Expand Down
5 changes: 3 additions & 2 deletions pages/02_libya.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def change_dataset(change):

def change_image(change):
if change.new:
mosaic = f'{url}/datasets/{dataset.value}/{image.value}.json'
m.add_stac_layer(mosaic, name=image.value, fit_bounds=m.zoom_to_layer)
if change.new not in m.get_layer_names():
mosaic = f'{url}/datasets/{dataset.value}/{image.value}.json'
m.add_stac_layer(mosaic, name=image.value, fit_bounds=m.zoom_to_layer)

image.observe(change_image, names='value')

Expand Down
5 changes: 3 additions & 2 deletions pages/03_maui.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ def change_dataset(change):

def change_image(change):
if change.new:
mosaic = f'{url}/datasets/{dataset.value}/{image.value}.json'
m.add_stac_layer(mosaic, name=image.value, fit_bounds=m.zoom_to_layer)
if change.new not in m.get_layer_names():
mosaic = f'{url}/datasets/{dataset.value}/{image.value}.json'
m.add_stac_layer(mosaic, name=image.value, fit_bounds=m.zoom_to_layer)

image.observe(change_image, names='value')

Expand Down

0 comments on commit 55b2b6f

Please sign in to comment.