Skip to content
Snippets Groups Projects
Commit 352a778e authored by Endrizzi, Marco (UG - Comp Sci & Elec Eng)'s avatar Endrizzi, Marco (UG - Comp Sci & Elec Eng)
Browse files

bad fix for users not being responsive

parent 2c50cb1a
No related branches found
No related tags found
No related merge requests found
...@@ -19,8 +19,9 @@ q-btn( ...@@ -19,8 +19,9 @@ q-btn(
</template> </template>
<script> <script>
import { mapState, mapActions } from 'vuex' import { mapState, mapActions, mapGetters } from 'vuex'
import axios from 'axios' import axios from 'axios'
var userMarkers = {}
export default { export default {
name: 'GoogleMap', name: 'GoogleMap',
...@@ -32,7 +33,6 @@ export default { ...@@ -32,7 +33,6 @@ export default {
heatmap: null, heatmap: null,
places: [], places: [],
crimes: [], crimes: [],
userMarkers: {},
dataFetched: false dataFetched: false
} }
}, },
...@@ -344,17 +344,16 @@ export default { ...@@ -344,17 +344,16 @@ export default {
mapsAddUserMarker(userId) { mapsAddUserMarker(userId) {
var userPosition = this.users[userId].position var userPosition = this.users[userId].position
let marker = new google.maps.Marker({ userMarkers[userId] = new google.maps.Marker({
position: new google.maps.LatLng(userPosition.lat, userPosition.lng), position: new google.maps.LatLng(userPosition.lat, userPosition.lng),
map: this.map, map: this.map,
icon: 'https://img.icons8.com/nolan/64/men-age-group-4--v2.png' icon: 'https://img.icons8.com/nolan/64/men-age-group-4--v2.png'
}) })
this.userMarkers[userId] = marker
}, },
mapsRemoveUserMarker(userId) { mapsRemoveUserMarker(userId) {
this.userMarkers[userId].setMap(null) userMarkers[userId].setMap(null)
delete this.userMarkers[userId] delete userMarkers[userId]
}, },
...mapActions('firebase', ['firebaseSavePosition']) ...mapActions('firebase', ['firebaseSavePosition'])
...@@ -370,13 +369,13 @@ export default { ...@@ -370,13 +369,13 @@ export default {
'latestSignalKey', 'latestSignalKey',
'events', 'events',
'latestEventKey' 'latestEventKey'
]) ]),
...mapGetters('firebase', ['latestUserChange'])
}, },
watch: { watch: {
latestUserChange: { latestUserChange: {
deep: true, deep: true,
immediate: true,
// Whenever a new event gets added, add it to the map // Whenever a new event gets added, add it to the map
handler() { handler() {
if (this.latestUserChange.type == 'add') { if (this.latestUserChange.type == 'add') {
...@@ -413,7 +412,7 @@ export default { ...@@ -413,7 +412,7 @@ export default {
} }
}, },
async mounted() { async created() {
// Wait for current location to be fetched and saved to store // Wait for current location to be fetched and saved to store
await this.geolocate() await this.geolocate()
// Wait for map and map components to be loaded // Wait for map and map components to be loaded
......
...@@ -433,6 +433,9 @@ const getters = { ...@@ -433,6 +433,9 @@ const getters = {
// Return the property names for the userDetails object // Return the property names for the userDetails object
userDetailsKeys: state => { userDetailsKeys: state => {
return Object.keys(state.userDetails) return Object.keys(state.userDetails)
},
latestUserChange: state => {
return state.latestUserChange
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment