Skip to content

Commit

Permalink
Convert MapDisplau to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
steinbro committed Nov 22, 2024
1 parent 237f64f commit d405c7b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
32 changes: 16 additions & 16 deletions src/components/MapDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@
<div id="map" ref="mapElement"></div>
</template>

<script setup>
import { ref, onMounted } from 'vue';
<script setup lang="ts">
import { ref, onMounted, withDefaults } from 'vue';
import * as L from 'leaflet';
import { useReactiveMapLayer } from '../composables/layer';
import { MappablePoint, useReactiveMapLayer } from '../composables/layer';
const props = defineProps({
location: Object,
beacon: Object,
follow: {
type: Boolean,
default: true,
},
pointOfInterest: Object,
interface MapProps {
location: MappablePoint,
beacon: MappablePoint,
follow: boolean,
pointOfInterest: MappablePoint,
}
const props = withDefaults(defineProps<MapProps>(), {
follow: true
});
const mapElement = ref(null);
const leafletMap = ref(null);
const mapElement = ref<string>();
const leafletMap = ref<L.Map>();
onMounted(() => {
leafletMap.value = L.map(mapElement.value);
leafletMap.value = L.map(mapElement.value!);
// Store the map instance in the map element for Cypress access
mapElement.value._leafletMap = leafletMap.value;
(mapElement.value as any)._leafletMap = leafletMap.value;
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors'
}).addTo(leafletMap.value);
}).addTo(leafletMap.value!);
});
// Plot current location
Expand Down
6 changes: 3 additions & 3 deletions src/composables/layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { Ref, watch, onMounted, onBeforeUnmount } from 'vue';
import L from 'leaflet';

interface MapOptions {
follow: boolean;
setMapView: boolean;
follow?: boolean;
setMapView?: boolean;
className: string,
iconSize: [number, number],
}
interface MappablePoint {
export interface MappablePoint {
latitude: number;
longitude: number;
heading?: number;
Expand Down

0 comments on commit d405c7b

Please sign in to comment.