Skip to content

Commit

Permalink
improve robustness on misconfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
warm-coolguy committed Jan 30, 2024
1 parent 9276631 commit 99bd162
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/plugins/LayerChooser/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## unpublished

- Fix: The LayerChooser plugin will keep working on the error that a layer without entry in the service register has been configured.

## 1.2.0

- Feature: Improved implementation to make plugin SPA-ready.
Expand Down
8 changes: 8 additions & 0 deletions packages/plugins/LayerChooser/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ export const makeStoreModule = () => {
id: layer.id,
})

if (rawLayer === null) {
console.error(
`@polar/plugin-layer-chooser: Layer ${layer.id} not found in service register. This is a configuration issue. The map might behave in unexpected ways.`,
layer
)
return
}

if (rawLayer.typ !== 'WMS' && !layer.hideInMenu) {
console.warn(
`@polar/plugin-layer-chooser: Used configuration 'layers' on layer with type '${
Expand Down
4 changes: 4 additions & 0 deletions packages/plugins/Legend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## unpublished

- Fix: The Legend plugin will keep working on the error that a layer without entry in the service register has been configured.

## 1.1.0

- Feature: Locale string layer names are now translated.
Expand Down
17 changes: 13 additions & 4 deletions packages/plugins/Legend/src/components/Legend.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,19 @@ export default Vue.extend({
id: layer.id,
}),
}))
.map((layer) => ({
...layer,
legendUrl: masterportalapi.layerLib.getLegendURLs(layer.rawLayer)[0],
}))
.map((layer) => {
if (layer.rawLayer === null) {
// skip undefined layers
console.warn(`@polar/plugin-legend: Unknown layer.`, layer)
return {}
}
return {
...layer,
legendUrl: masterportalapi.layerLib.getLegendURLs(
layer.rawLayer
)[0],
}
})
.filter((layer) => layer.name && layer.legendUrl)
},
},
Expand Down

0 comments on commit 99bd162

Please sign in to comment.