Add mapbox-key to map interface initialization (#7602)

This commit is contained in:
Oreille
2021-08-25 15:33:27 +02:00
committed by GitHub
parent 7cc15f2d40
commit d4999a4d39

View File

@@ -31,6 +31,7 @@ import { getBasemapSources, getStyleFromBasemapSource } from '@/utils/geometry/b
import 'maplibre-gl/dist/maplibre-gl.css';
import { Map, CameraOptions } from 'maplibre-gl';
import { useAppStore } from '@/stores';
import getSetting from '@/utils/get-setting';
export default defineComponent({
props: {
@@ -73,6 +74,7 @@ export default defineComponent({
const mapContainer = ref<HTMLElement | null>(null);
let map: Map;
const mapboxKey = getSetting('mapbox_key');
const basemaps = getBasemapSources();
const appStore = useAppStore();
const { basemap } = toRefs(appStore);
@@ -87,6 +89,7 @@ export default defineComponent({
style: style.value,
attributionControl: false,
...(defaultView.value || {}),
...(mapboxKey ? { accessToken: mapboxKey } : {}),
});
map.on('moveend', () => {
defaultView.value = {