mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Translate and make it reactive
- Simplify coding of styles.
This commit is contained in:
parent
e53ccb8d59
commit
41ecc2df9e
@ -522,6 +522,14 @@
|
|||||||
"questions": "Bei Fragen oder Problemen erreichst Du uns per E-Mail an",
|
"questions": "Bei Fragen oder Problemen erreichst Du uns per E-Mail an",
|
||||||
"title": "{APPLICATION_NAME} befindet sich in der Wartung"
|
"title": "{APPLICATION_NAME} befindet sich in der Wartung"
|
||||||
},
|
},
|
||||||
|
"map": {
|
||||||
|
"styles": {
|
||||||
|
"outdoors": "Landschaft",
|
||||||
|
"dark": "Dunkel",
|
||||||
|
"satellite": "Satellit",
|
||||||
|
"streets": "Straßen"
|
||||||
|
}
|
||||||
|
},
|
||||||
"modals": {
|
"modals": {
|
||||||
"deleteUser": {
|
"deleteUser": {
|
||||||
"created": "Erstellt"
|
"created": "Erstellt"
|
||||||
|
|||||||
@ -522,6 +522,14 @@
|
|||||||
"questions": "Any Questions or concerns, send an e-mail to",
|
"questions": "Any Questions or concerns, send an e-mail to",
|
||||||
"title": "{APPLICATION_NAME} is under maintenance"
|
"title": "{APPLICATION_NAME} is under maintenance"
|
||||||
},
|
},
|
||||||
|
"map": {
|
||||||
|
"styles": {
|
||||||
|
"outdoors": "Outdoors",
|
||||||
|
"dark": "Dark",
|
||||||
|
"satellite": "Satellite",
|
||||||
|
"streets": "Streets"
|
||||||
|
}
|
||||||
|
},
|
||||||
"modals": {
|
"modals": {
|
||||||
"deleteUser": {
|
"deleteUser": {
|
||||||
"created": "Created"
|
"created": "Created"
|
||||||
|
|||||||
@ -35,40 +35,52 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import mapboxgl from 'mapbox-gl'
|
import mapboxgl from 'mapbox-gl'
|
||||||
|
import { objectValuesToArray } from '../utils/utils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Map',
|
name: 'Map',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
mapboxgl,
|
mapboxgl,
|
||||||
mapOptions: {
|
activeStyle: null,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
styles() {
|
||||||
|
return {
|
||||||
|
available: objectValuesToArray(this.availableStyles),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
availableStyles() {
|
||||||
|
// https://docs.mapbox.com/api/maps/styles/
|
||||||
|
const availableStyles = {
|
||||||
|
outdoors: {
|
||||||
|
url: 'mapbox://styles/mapbox/outdoors-v12?optimize=true',
|
||||||
|
},
|
||||||
|
streets: {
|
||||||
|
url: 'mapbox://styles/mapbox/streets-v11?optimize=true',
|
||||||
|
},
|
||||||
|
satellite: {
|
||||||
|
url: 'mapbox://styles/mapbox/satellite-streets-v11?optimize=true',
|
||||||
|
},
|
||||||
|
dark: {
|
||||||
|
url: 'mapbox://styles/mapbox/dark-v10?optimize=true',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
Object.keys(availableStyles).map((key) => {
|
||||||
|
availableStyles[key].title = this.$t('map.styles.' + key)
|
||||||
|
})
|
||||||
|
return availableStyles
|
||||||
|
},
|
||||||
|
mapOptions() {
|
||||||
|
return {
|
||||||
accessToken: this.$env.MAPBOX_TOKEN,
|
accessToken: this.$env.MAPBOX_TOKEN,
|
||||||
style: 'mapbox://styles/mapbox/outdoors-v12?optimize=true',
|
style: !this.activeStyle ? this.availableStyles.outdoors.url : this.activeStyle,
|
||||||
center: [10.452764, 51.165707], // center of Germany
|
center: [10.452764, 51.165707], // center of Germany
|
||||||
zoom: 4,
|
zoom: 4,
|
||||||
maxZoom: 22,
|
maxZoom: 22,
|
||||||
},
|
}
|
||||||
styles: {
|
},
|
||||||
// https://docs.mapbox.com/api/maps/styles/
|
|
||||||
available: [
|
|
||||||
{
|
|
||||||
title: 'Outdoors',
|
|
||||||
url: 'mapbox://styles/mapbox/outdoors-v12?optimize=true',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Streets',
|
|
||||||
url: 'mapbox://styles/mapbox/streets-v11?optimize=true',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Satellite',
|
|
||||||
url: 'mapbox://styles/mapbox/satellite-streets-v11?optimize=true',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Dark',
|
|
||||||
url: 'mapbox://styles/mapbox/dark-v10?optimize=true',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onMapLoad({ map }) {
|
onMapLoad({ map }) {
|
||||||
@ -76,7 +88,7 @@ export default {
|
|||||||
},
|
},
|
||||||
setStyle(url) {
|
setStyle(url) {
|
||||||
this.map.setStyle(url)
|
this.map.setStyle(url)
|
||||||
this.mapOptions.style = url
|
this.activeStyle = url
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
5
webapp/utils/utils.js
Normal file
5
webapp/utils/utils.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
export const objectValuesToArray = (obj) => {
|
||||||
|
return Object.keys(obj).map(function (key) {
|
||||||
|
return obj[key]
|
||||||
|
})
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user