From a24cb976aae68aba0b94e41d77f3718a058bfd08 Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Tue, 16 May 2023 11:39:49 -0300 Subject: [PATCH] mission-planning: Add home marker to the planning view --- src/views/MissionPlanningView.vue | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/views/MissionPlanningView.vue b/src/views/MissionPlanningView.vue index 1d1fe97b3..0d54a1fe4 100644 --- a/src/views/MissionPlanningView.vue +++ b/src/views/MissionPlanningView.vue @@ -339,6 +339,30 @@ watch(vehicleStore.coordinates, () => { vehicleMarker.value.setLatLng(position as LatLngTuple) }) +const homeMarker = ref() +watch(home, () => { + if (planningMap.value === undefined) throw new Error('Map not yet defined') + + const position = home.value + if (position === undefined) return + + if (homeMarker.value === undefined) { + homeMarker.value = L.marker(position as LatLngTuple) + var homeMarkerIcon = L.divIcon({ className: 'marker-icon', iconSize: [16, 16], iconAnchor: [8, 8] }) + homeMarker.value.setIcon(homeMarkerIcon) + const homeMarkerTooltip = L.tooltip({ + content: 'H', + permanent: true, + direction: 'center', + className: 'waypoint-tooltip', + opacity: 1, + }) + homeMarker.value.bindTooltip(homeMarkerTooltip) + planningMap.value.addLayer(homeMarker.value) + } + homeMarker.value.setLatLng(home.value) +}) + watch(planningMap, (newMap, oldMap) => { if (planningMap.value !== undefined && newMap?.options === undefined) { planningMap.value = oldMap