Skip to content

Commit

Permalink
mission-planning: Add vehicle marker to the planning view
Browse files Browse the repository at this point in the history
Make it easier to know where to draw the mission
  • Loading branch information
rafaellehmkuhl committed May 16, 2023
1 parent 73e9627 commit 118dcc1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/views/MissionPlanningView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,32 @@ onMounted(() => {
planningMap.value.addControl(layerControl)
})
const vehicleMarker = ref<L.Marker>()
watch(vehicleStore.coordinates, () => {
if (planningMap.value === undefined) throw new Error('Map not yet defined')
const position = vehicleStore.coordinates.latitude
? [vehicleStore.coordinates.latitude, vehicleStore.coordinates.longitude]
: undefined
if (position === undefined) return
if (vehicleMarker.value === undefined) {
vehicleMarker.value = L.marker(position as LatLngTuple)
var vehicleMarkerIcon = L.divIcon({ className: 'marker-icon', iconSize: [16, 16], iconAnchor: [8, 8] })
vehicleMarker.value.setIcon(vehicleMarkerIcon)
const vehicleMarkerTooltip = L.tooltip({
content: 'V',
permanent: true,
direction: 'center',
className: 'waypoint-tooltip',
opacity: 1,
})
vehicleMarker.value.bindTooltip(vehicleMarkerTooltip)
planningMap.value.addLayer(vehicleMarker.value)
}
vehicleMarker.value.setLatLng(position as LatLngTuple)
})
watch(planningMap, (newMap, oldMap) => {
if (planningMap.value !== undefined && newMap?.options === undefined) {
planningMap.value = oldMap
Expand Down

0 comments on commit 118dcc1

Please sign in to comment.