From fe07e6283c993141d5a8e50ffb9e3944dcd56f6f Mon Sep 17 00:00:00 2001 From: James Lyne Date: Wed, 16 Dec 2020 18:49:41 +0000 Subject: [PATCH] Handle player hiding correctly --- src/components/map/marker/PlayerMarker.vue | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/components/map/marker/PlayerMarker.vue b/src/components/map/marker/PlayerMarker.vue index 6f36e76..54a2a78 100644 --- a/src/components/map/marker/PlayerMarker.vue +++ b/src/components/map/marker/PlayerMarker.vue @@ -55,15 +55,16 @@ export default defineComponent({ player: { deep: true, handler(newValue) { - if(this.visible) { - this.marker!.setLatLng(this.currentProjection.locationToLatLng(newValue.location)); - - // if(this.following) { - // - // } + if(this.currentWorld && newValue.location.world === this.currentWorld.name) { + if(!this.visible) { + this.enableLayer(); + } else { + this.marker!.setLatLng(this.currentProjection.locationToLatLng(newValue.location)); + this.marker!.getIcon().update(); + } + } else if(this.visible) { + this.disableLayer(); } - - this.marker!.getIcon().update(); }, }, currentWorld(newValue) { @@ -88,6 +89,10 @@ export default defineComponent({ pane: 'players', }); + if(this.currentWorld) { + console.log(this.currentWorld.name, this.player.location.world); + } + if(this.currentWorld && this.currentWorld.name === this.player.location.world) { this.enableLayer(); } @@ -105,18 +110,14 @@ export default defineComponent({ methods: { enableLayer() { - // console.log('Enabling marker for ' + this.player.name); - - if(this.marker) { + if(this.marker && !this.visible) { this.layerGroup.addLayer(this.marker); this.marker.setLatLng(this.currentProjection.locationToLatLng(this.player.location)); this.visible = true; } }, disableLayer() { - // console.log('Disabling marker for ' + this.player.name); - - if(this.marker) { + if(this.marker && this.visible) { this.layerGroup.removeLayer(this.marker); this.visible = false; }