Skip to content

Commit

Permalink
fix: type error #226
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab committed Sep 30, 2024
1 parent 250d7e6 commit 01446bd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions components/Map/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
MapTouchEvent,
RasterSourceSpecification,
StyleSpecification,
VectorSourceSpecification,
} from 'maplibre-gl'
import {
Expand All @@ -30,7 +31,6 @@ import { MapStyleEnum } from '~/utils/types'
type ITMap = InstanceType<typeof Map>
type ITAttributionControl = InstanceType<typeof AttributionControl>
type ITFullscreenControl = InstanceType<typeof FullscreenControl>
export default defineNuxtComponent({
props: {
Expand Down Expand Up @@ -89,9 +89,15 @@ export default defineNuxtComponent({
setup() {
const { config } = storeToRefs(useSiteStore())
const fullscreenControlObject = ref<FullscreenControl>()
onMounted(() => {
fullscreenControlObject.value = new FullscreenControl()
})
return {
config,
fullscreenControlObject,
}
},
Expand All @@ -101,7 +107,6 @@ export default defineNuxtComponent({
mapStyleCache: { [key: string]: StyleSpecification }
attributionControl: ITAttributionControl | null
languageControl: OpenMapTilesLanguage | null
fullscreenControlObject: ITFullscreenControl | undefined
withMap: any[]
} {
return {
Expand All @@ -110,15 +115,11 @@ export default defineNuxtComponent({
mapStyleCache: {},
attributionControl: null,
languageControl: null,
fullscreenControlObject: undefined,
withMap: [],
}
},
mounted() {
// @ts-expect-error: type is too deep
this.fullscreenControlObject = new FullscreenControl()
const map = new Map({
container: 'map',
style: (this.style as StyleSpecification) || {
Expand Down Expand Up @@ -175,7 +176,7 @@ export default defineNuxtComponent({
map.addControl(geolocateControl)
geolocateControl._container.classList.add('control-geolocate')
if (this.fullscreenControl)
if (this.fullscreenControl && this.fullscreenControlObject)
map.addControl(this.fullscreenControlObject)
map.addControl(
Expand Down

0 comments on commit 01446bd

Please sign in to comment.