提交 426cfe6a 作者: 方治民

chore: Upgrade mapbox-gl-js v2.14.1

上级 69e48a7c
import type { Ref } from 'vue'
import { toRaw } from 'vue'
import type mapboxgl from 'mapbox-gl'
import { toRaw } from 'vue'
import { appendScript, appendStylesheet } from '/@/utils/dom'
// Mapbox accessToken
export const accessToken = 'pk.eyJ1IjoiaWZ6bSIsImEiOiJjamswc3M1a2gwYWEwM3Zxa3ZsMjh3djkwIn0.h93-XtdRdtoC1KbVv_ZIow'
......@@ -531,6 +532,20 @@ export function createPopupHtml(entry: Recordable, mapping: Recordable) {
return htmls.join('')
}
/**
* 加载地图依赖库
*/
export function loadMapboxLibs() {
const id = 'mapbox-gl'
const version = '2.14.1'
const resource = `static/mapbox-gl-js/${version}/${id}`
return Promise.all([
appendScript(id, `${resource}.js`),
appendStylesheet(id, `${resource}.css`),
appendStylesheet(id, `${resource}.extra.css`),
])
}
export const getMapInstance = (ref: Ref<any>): mapboxgl.Map => toRaw(ref.value?.map) as mapboxgl.Map
export const getGeoJSONSource = (map: mapboxgl.Map, sourceName: string): mapboxgl.GeoJSONSource =>
map.getSource(sourceName) as mapboxgl.GeoJSONSource
......
import { appendScript, appendStylesheet } from '/@/utils/dom'
import { accessToken, defaultStyle, loadMapControl } from '/@/components/Map/Mapbox'
import { accessToken, defaultStyle, loadMapControl, loadMapboxLibs } from '/@/components/Map/Mapbox'
// renderjs 官方文档
// https://uniapp.dcloud.io/tutorial/renderjs.html
......@@ -9,15 +8,7 @@ import { accessToken, defaultStyle, loadMapControl } from '/@/components/Map/Map
export default {
mounted() {},
methods: {
loadLibs() {
const id = 'mapbox-gl'
const resource = 'static/mapbox-gl-js/v2.13.0/mapbox-gl'
return Promise.all([
appendScript(id, `${resource}.js`),
appendStylesheet(id, `${resource}.css`),
appendStylesheet(id, `${resource}.extra.css`),
])
},
loadLibs: loadMapboxLibs,
initMap(options) {
// 移除地图
if (this.map && this.map.remove) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论