-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vinayak Kulkarni <[email protected]>
- Loading branch information
1 parent
5d7a8dd
commit 4f5a2eb
Showing
21 changed files
with
499 additions
and
632 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const popupEvents = ['open', 'close']; | ||
export const popupEvents = ['open', 'close'] as Array<'open' | 'close'>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export type { AttributionOptions, ControlPosition } from 'maplibre-gl'; | ||
export type { AttributionControlOptions, ControlPosition } from 'maplibre-gl'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export type { ControlPosition, FullscreenOptions } from 'maplibre-gl'; | ||
export type { FullscreenControlOptions, ControlPosition } from 'maplibre-gl'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export type { ControlPosition, GeolocateOptions } from 'maplibre-gl'; | ||
export type { GeolocateControlOptions, ControlPosition } from 'maplibre-gl'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export type { ControlPosition, ScaleOptions } from 'maplibre-gl'; | ||
export type { ControlPosition, ScaleControlOptions } from 'maplibre-gl'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 59 additions & 71 deletions
130
lib/v-mapbox/layers/maplibre/image/VLayerMaplibreImage.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,76 @@ | ||
<script lang="ts"> | ||
<script setup lang="ts"> | ||
import type { | ||
LayerSpecification as AnyLayer, | ||
ImageSourceSpecification as ImageSourceRaw, | ||
} from 'maplibre-gl'; | ||
import type { PropType, Ref } from 'vue'; | ||
import { defineComponent, onMounted, ref, watch } from 'vue'; | ||
import { ref, watch, onMounted } from 'vue'; | ||
import { injectStrict, MapKey } from '../../../utils'; | ||
export default defineComponent({ | ||
name: 'VLayerMapboxImage', | ||
props: { | ||
sourceId: { | ||
type: String as PropType<string>, | ||
default: 'maplibre.gl-image-source', | ||
required: true, | ||
}, | ||
layerId: { | ||
type: String as PropType<string>, | ||
default: 'maplibre.gl-image-layer', | ||
required: true, | ||
}, | ||
source: { | ||
type: Object as PropType<ImageSourceRaw>, | ||
required: true, | ||
}, | ||
layer: { | ||
type: Object as PropType<AnyLayer>, | ||
default: () => ({}), | ||
required: true, | ||
}, | ||
before: { | ||
type: String as PropType<string>, | ||
default: '', | ||
required: false, | ||
}, | ||
const props = defineProps({ | ||
sourceId: { | ||
type: String, | ||
default: 'maplibre.gl-image-source', | ||
required: true, | ||
}, | ||
setup(props) { | ||
let map = injectStrict(MapKey); | ||
let loaded: Ref<boolean> = ref(false); | ||
layerId: { | ||
type: String, | ||
default: 'maplibre.gl-image-layer', | ||
required: true, | ||
}, | ||
source: { | ||
type: Object as PropType<ImageSourceRaw>, | ||
required: true, | ||
}, | ||
layer: { | ||
type: Object as PropType<AnyLayer>, | ||
default: () => ({}), | ||
required: true, | ||
}, | ||
before: { | ||
type: String, | ||
default: '', | ||
required: false, | ||
}, | ||
}); | ||
const layer = { | ||
...props.layer, | ||
id: props.layerId, | ||
source: props.sourceId, | ||
}; | ||
const map = injectStrict(MapKey); | ||
const loaded = ref(false); | ||
map.value.on('style.load', () => { | ||
// https://github.com/mapbox/mapbox-gl-js/issues/2268#issuecomment-401979967 | ||
const styleTimeout = () => { | ||
if (!map.value.isStyleLoaded()) { | ||
loaded.value = false; | ||
setTimeout(styleTimeout, 200); | ||
} else { | ||
loaded.value = true; | ||
} | ||
}; | ||
styleTimeout(); | ||
}); | ||
const layer = { | ||
...props.layer, | ||
id: props.layerId, | ||
source: props.sourceId, | ||
}; | ||
/** | ||
* Watcher(s) | ||
*/ | ||
watch(loaded, (value) => { | ||
if (value) { | ||
addLayer(); | ||
} | ||
}); | ||
map.value.on('style.load', () => { | ||
// https://github.com/mapbox/mapbox-gl-js/issues/2268#issuecomment-401979967 | ||
const styleTimeout = () => { | ||
if (!map.value.isStyleLoaded()) { | ||
loaded.value = false; | ||
setTimeout(styleTimeout, 200); | ||
} else { | ||
loaded.value = true; | ||
} | ||
}; | ||
styleTimeout(); | ||
}); | ||
onMounted(() => { | ||
addLayer(); | ||
}); | ||
watch(loaded, (value) => { | ||
if (value) { | ||
addLayer(); | ||
} | ||
}); | ||
/** | ||
* Re–adds the layer when style changed | ||
* @returns {void} | ||
*/ | ||
function addLayer(): void { | ||
map.value.addSource(props.sourceId, props.source); | ||
map.value.addLayer(layer, props.before); | ||
} | ||
}, | ||
onMounted(() => { | ||
addLayer(); | ||
}); | ||
const addLayer = (): void => { | ||
map.value.addSource(props.sourceId, props.source); | ||
map.value.addLayer(layer, props.before); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<slot /> | ||
<slot></slot> | ||
</template> |
Oops, something went wrong.