Skip to content

Commit

Permalink
Use seperate fields for lattitude and longitude
Browse files Browse the repository at this point in the history
  • Loading branch information
wkramer committed Sep 24, 2024
1 parent 1b0196e commit 49b98e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/components/map/CoordinateSelectorControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
<v-chip pill label class="outer-chip chip justify-center overflow-visible">
<v-icon class="pr-2">mdi-map-marker</v-icon>

<span class="mr-4 text-medium-emphasis text-mono">
{{ coordinateString }}
<span class="coordinate-selector__value text-right mr-1">
{{ coordinateStringParts[0] }}
</span>
<span class="coordinate-selector__value text-right mr-2">
{{ coordinateStringParts[1] }}
</span>
<v-btn
:disabled="coordinate === null"
@click="onFinish"
density="compact"
color="primary"
class="px-0 text-medium-emphasis"
class="px-0"
>
Apply
</v-btn>
</v-chip>
</template>

<script setup lang="ts">
import { coordinateToString } from '@/lib/workflows'
import { coordinateToStringParts } from '@/lib/workflows'
import type { LngLat } from 'maplibre-gl'
import { computed } from 'vue'
Expand All @@ -27,7 +30,9 @@ const coordinate = defineModel<LngLat | null>('coordinate', {
})
const isActive = defineModel<boolean>('active', { default: false })
const coordinateString = computed(() => coordinateToString(coordinate.value))
const coordinateStringParts = computed(() =>
coordinateToStringParts(coordinate.value),
)
function onFinish(): void {
isActive.value = false
Expand All @@ -42,4 +47,8 @@ function onFinish(): void {
background-color: rgba(var(--v-theme-surface), 0.8);
box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}
.coordinate-selector__value {
min-width: calc(4ch + 2em);
}
</style>
6 changes: 6 additions & 0 deletions src/lib/workflows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ export function coordinateToString(coordinate: LngLat | null) {
? `${coordinate.lng.toFixed(2)}°E ${coordinate.lat.toFixed(2)}°N`
: '—'
}

export function coordinateToStringParts(coordinate: LngLat | null) {
return coordinate
? [`${coordinate.lng.toFixed(2)}°E`, `${coordinate.lat.toFixed(2)}°N`]
: ['—°E', '—°N']
}

0 comments on commit 49b98e1

Please sign in to comment.