Skip to content

Commit

Permalink
wip: Provide an attribution component #473
Browse files Browse the repository at this point in the history
  • Loading branch information
cnouguier committed Oct 29, 2024
1 parent 3b31c3f commit 112e923
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion map/client/components/KAttribution.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

<script setup>
import _ from 'lodash'
import logger from 'loglevel'
import { ref, computed, watch } from 'vue'
import { Document } from '../../../core/client/document.js'
import { KShape } from '../../../core/client/components/media'
Expand All @@ -50,7 +51,7 @@ const attributions = ref({})
// Computed
const sanitizedAttributions = computed(() => {
let content = ''
_.forEach(attributions.value, (attribution, layer) => {
_.forOwn(attributions.value, (attribution, layer) => {
content += `${attribution}<br>`
})
return Document.sanitizeHtml(content)
Expand Down Expand Up @@ -79,11 +80,13 @@ watch(CurrentActivity, (newActivity, oldActivity) => {
// Functions
function onShowLayer (layer, engine) {
if (layer.attribution) {
logger.debug(`[KDK] Add ${layer.name} to attribution`)
_.set(attributions.value, _.kebabCase(layer.name), layer.attribution)
}
}
function onHideLayer (layer) {
if (layer.attribution) {
logger.debug(`[KDK] Remove ${layer.name} from attribution`)
_.unset(attributions.value, _.kebabCase(layer.name))
}
}
Expand Down

0 comments on commit 112e923

Please sign in to comment.