mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Show all users with locations on map
This commit is contained in:
parent
e8d21147ae
commit
36239bc762
@ -97,10 +97,9 @@ export const mapUserQuery = (i18n) => {
|
|||||||
${locationFragment(lang)}
|
${locationFragment(lang)}
|
||||||
${badgesFragment}
|
${badgesFragment}
|
||||||
|
|
||||||
query User() {
|
query {
|
||||||
User() {
|
User {
|
||||||
...user
|
...user
|
||||||
...userCounts
|
|
||||||
...location
|
...location
|
||||||
...badges
|
...badges
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,11 +39,13 @@
|
|||||||
<MglNavigationControl position="top-right" />
|
<MglNavigationControl position="top-right" />
|
||||||
<MglGeolocateControl position="top-right" />
|
<MglGeolocateControl position="top-right" />
|
||||||
<MglScaleControl />
|
<MglScaleControl />
|
||||||
|
<div v-for="user in users" :key="user.id">
|
||||||
<MglMarker
|
<MglMarker
|
||||||
v-if="this.currentUserCoordinates"
|
v-if="user.location"
|
||||||
:coordinates="this.currentUserCoordinates"
|
:coordinates="getCoordinates(user.location)"
|
||||||
color="blue"
|
:color="user.id === currentUser.id ? 'red' : 'blue'"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
</mgl-map>
|
</mgl-map>
|
||||||
</client-only>
|
</client-only>
|
||||||
</div>
|
</div>
|
||||||
@ -54,7 +56,7 @@ import mapboxgl from 'mapbox-gl'
|
|||||||
// import MapboxLanguage from '@mapbox/mapbox-gl-language'
|
// import MapboxLanguage from '@mapbox/mapbox-gl-language'
|
||||||
import { objectValuesToArray } from '../utils/utils'
|
import { objectValuesToArray } from '../utils/utils'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
import { profileUserQuery } from '~/graphql/User'
|
import { profileUserQuery, mapUserQuery } from '~/graphql/User'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Map',
|
name: 'Map',
|
||||||
@ -70,12 +72,13 @@ export default {
|
|||||||
defaultCenter: [10.452764, 51.165707], // center of Germany: https://www.gpskoordinaten.de/karte/land/DE
|
defaultCenter: [10.452764, 51.165707], // center of Germany: https://www.gpskoordinaten.de/karte/land/DE
|
||||||
currentUserLocation: null,
|
currentUserLocation: null,
|
||||||
currentUserCoordinates: null,
|
currentUserCoordinates: null,
|
||||||
|
users: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.currentUserLocation = await this.getUserLocation(this.currentUser.id)
|
this.currentUserLocation = await this.getUserLocation(this.currentUser.id)
|
||||||
this.currentUserCoordinates = this.currentUserLocation
|
this.currentUserCoordinates = this.currentUserLocation
|
||||||
? [this.currentUserLocation.lng, this.currentUserLocation.lat]
|
? [this.currentUserLocation.lng, this.currentUserLocation.lat] // Wolle: getCoordinates
|
||||||
: null
|
: null
|
||||||
this.mapFlyToCenter()
|
this.mapFlyToCenter()
|
||||||
},
|
},
|
||||||
@ -159,6 +162,9 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getCoordinates(location) {
|
||||||
|
return [location.lng, location.lat]
|
||||||
|
},
|
||||||
async getUserLocation(id) {
|
async getUserLocation(id) {
|
||||||
try {
|
try {
|
||||||
const {
|
const {
|
||||||
@ -178,6 +184,20 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
apollo: {
|
||||||
|
User: {
|
||||||
|
query() {
|
||||||
|
return mapUserQuery(this.$i18n)
|
||||||
|
},
|
||||||
|
variables() {
|
||||||
|
return {}
|
||||||
|
},
|
||||||
|
update({ User }) {
|
||||||
|
this.users = User
|
||||||
|
},
|
||||||
|
fetchPolicy: 'cache-and-network',
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user