Simplify the map legend

This commit is contained in:
Wolfgang Huß 2023-07-11 12:14:21 +02:00
parent 6c32eb918d
commit 11afa1f6d5

View File

@ -5,33 +5,15 @@
<ds-heading tag="h1">{{ $t('map.pageTitle') }}</ds-heading> <ds-heading tag="h1">{{ $t('map.pageTitle') }}</ds-heading>
<small> <small>
<div> <div>
<span v-for="type in markers.types" :key="type.id">
<img <img
:alt="$t('map.legend.theUser')" :alt="$t('map.legend.' + type.id)"
src="/img/mapbox/marker-icons/mapbox-marker-icon-orange.svg" :src="'/img/mapbox/marker-icons/' + type.icon.legendName"
width="15" width="15"
/> />
{{ $t('map.legend.theUser') }} {{ $t('map.legend.' + type.id) }}
&nbsp;&nbsp; &nbsp;&nbsp;
<img </span>
:alt="$t('map.legend.user')"
src="/img/mapbox/marker-icons/mapbox-marker-icon-green.svg"
width="15"
/>
{{ $t('map.legend.user') }}
&nbsp;&nbsp;
<img
:alt="$t('map.legend.group')"
src="/img/mapbox/marker-icons/mapbox-marker-icon-blue.svg"
width="15"
/>
{{ $t('map.legend.group') }}
&nbsp;&nbsp;
<img
:alt="$t('map.legend.event')"
src="/img/mapbox/marker-icons/mapbox-marker-icon-purple.svg"
width="15"
/>
{{ $t('map.legend.event') }}
</div> </div>
</small> </small>
</ds-space> </ds-space>
@ -115,22 +97,38 @@ export default {
groups: null, groups: null,
posts: null, posts: null,
markers: { markers: {
icons: [ types: [
{
id: 'marker-blue',
name: 'mapbox-marker-icon-20px-blue.png',
},
{
id: 'marker-green',
name: 'mapbox-marker-icon-20px-green.png',
},
{ {
id: 'theUser',
icon: {
id: 'marker-orange', id: 'marker-orange',
name: 'mapbox-marker-icon-20px-orange.png', legendName: 'mapbox-marker-icon-orange.svg',
mapName: 'mapbox-marker-icon-20px-orange.png',
},
}, },
{ {
id: 'user',
icon: {
id: 'marker-green',
legendName: 'mapbox-marker-icon-green.svg',
mapName: 'mapbox-marker-icon-20px-green.png',
},
},
{
id: 'group',
icon: {
id: 'marker-blue',
legendName: 'mapbox-marker-icon-blue.svg',
mapName: 'mapbox-marker-icon-20px-blue.png',
},
},
{
id: 'event',
icon: {
id: 'marker-purple', id: 'marker-purple',
name: 'mapbox-marker-icon-20px-purple.png', legendName: 'mapbox-marker-icon-purple.svg',
mapName: 'mapbox-marker-icon-20px-purple.png',
},
}, },
], ],
isImagesLoaded: false, isImagesLoaded: false,
@ -339,15 +337,18 @@ export default {
}, },
loadMarkersIconsAndAddMarkers() { loadMarkersIconsAndAddMarkers() {
Promise.all( Promise.all(
this.markers.icons.map( this.markers.types.map(
(marker) => (marker) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
// our images have to be in the 'static/img/*' folder otherwise they are not reachable via URL // our images have to be in the 'static/img/*' folder otherwise they are not reachable via URL
this.map.loadImage('img/mapbox/marker-icons/' + marker.name, (error, image) => { this.map.loadImage(
'img/mapbox/marker-icons/' + marker.icon.mapName,
(error, image) => {
if (error) throw error if (error) throw error
this.map.addImage(marker.id, image) this.map.addImage(marker.icon.id, image)
resolve() resolve()
}) },
)
}), }),
), ),
).then(() => { ).then(() => {