Added check if there is no player data

This commit is contained in:
Alexis
2023-12-08 19:26:39 +01:00
parent 873743d732
commit e2b513253c
2 changed files with 5 additions and 2 deletions

View File

@@ -158,7 +158,8 @@ for (let i = 0; i < markers.length; i++) {
/**
* Add player's position marker
*/
if ( players ) {
if ( players && Object.keys(players).length > 0 ) {
console.log(players)
const playersPosition =[
convertYToScale(players.markerCoords.y),
convertXToScale(players.markerCoords.x)

View File

@@ -60,6 +60,8 @@ onMounted(() => {
})
})
const hasPlayers = computed(() => Object.keys(props.players).length > 0)
/**
* Marker geolocation
* We need to use onUpdated hook because the list is not always rendered, and it often rebuilt.
@@ -83,7 +85,7 @@ onUpdated(() => {
<i class="search-icon ph-fill ph-magnifying-glass"></i>
<input ref="qInput" name="recherche" type="text" v-model="q" title="Rechercher le monde" placeholder="Ville, point d'intérêt…">
<button data-to-players class="player-btn" :tabindex="shouldBeActive ? 1 : 0" title="Aller à la position actuelle des joueurs">
<button v-if="hasPlayers" data-to-players class="player-btn" :tabindex="shouldBeActive ? 1 : 0" title="Aller à la position actuelle des joueurs">
<i class="pin-icon ph-fill ph-map-pin"></i>
</button>
</div>