Fix hot-reloading Map component

This commit is contained in:
James Lyne 2021-05-28 19:50:08 +01:00
parent 54742f90f9
commit 387c92e3cb

View File

@ -16,6 +16,7 @@
<template> <template>
<div class="map" :style="{backgroundColor: mapBackground }" v-bind="$attrs" :aria-label="mapTitle"> <div class="map" :style="{backgroundColor: mapBackground }" v-bind="$attrs" :aria-label="mapTitle">
<template v-if="leaflet">
<MapLayer v-for="[name, map] in maps" :key="name" :map="map" :name="name" :leaflet="leaflet"></MapLayer> <MapLayer v-for="[name, map] in maps" :key="name" :map="map" :name="name" :leaflet="leaflet"></MapLayer>
<PlayersLayer v-if="playerMarkersEnabled" :leaflet="leaflet"></PlayersLayer> <PlayersLayer v-if="playerMarkersEnabled" :leaflet="leaflet"></PlayersLayer>
<MarkerSetLayer v-for="[name, markerSet] in markerSets" :key="name" :markerSet="markerSet" :leaflet="leaflet"></MarkerSetLayer> <MarkerSetLayer v-for="[name, markerSet] in markerSets" :key="name" :markerSet="markerSet" :leaflet="leaflet"></MarkerSetLayer>
@ -25,6 +26,7 @@
<LinkControl v-if="linkControlEnabled" :leaflet="leaflet"></LinkControl> <LinkControl v-if="linkControlEnabled" :leaflet="leaflet"></LinkControl>
<ClockControl v-if="clockControlEnabled" :leaflet="leaflet"></ClockControl> <ClockControl v-if="clockControlEnabled" :leaflet="leaflet"></ClockControl>
<ChatControl v-if="chatBoxEnabled" :leaflet="leaflet"></ChatControl> <ChatControl v-if="chatBoxEnabled" :leaflet="leaflet"></ChatControl>
</template>
</div> </div>
<MapContextMenu :leaflet="leaflet" v-if="leaflet"></MapContextMenu> <MapContextMenu :leaflet="leaflet" v-if="leaflet"></MapContextMenu>
</template> </template>
@ -225,6 +227,7 @@ export default defineComponent({
unmounted() { unmounted() {
window.removeEventListener('keydown', this.handleKeydown); window.removeEventListener('keydown', this.handleKeydown);
this.leaflet.remove();
}, },
methods: { methods: {