Skip to content

Commit 0a8e201

Browse files
committed
feat: learn mapbox
1 parent 12aa8b6 commit 0a8e201

File tree

16 files changed

+438
-5
lines changed

16 files changed

+438
-5
lines changed

.vitepress/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ export default defineConfig({
4747
},
4848
},
4949
vite: {
50-
resolve: { alias: { 'coding-playground': resolve(__dirname, '../packages') } },
50+
resolve: { alias: { '~': resolve(__dirname, '../packages') } },
5151
plugins: [
5252
AutoImport({
53+
imports: ['vue'],
5354
dts: true,
5455
resolvers: [ElementPlusResolver()],
5556
}),

.vitepress/sidebar.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export default <DefaultTheme.Sidebar>[
1616
{
1717
text: 'GIS',
1818
items: [
19-
19+
{ text: 'Mapbox入门', link: '/packages/gis/mapbox/getting-started' },
20+
{ text: '点击飞行效果', link: '/packages/gis/mapbox/fly-to' },
21+
{ text: '地球自转效果', link: '/packages/gis/mapbox/rotation' },
2022
],
2123
},
2224
]

.vitepress/theme/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import DefaultTheme from 'vitepress/theme'
44
import '@vitepress-demo-preview/component/dist/style.css'
55
import './base.css'
66
import 'virtual:uno.css'
7+
import 'mapbox-gl/dist/mapbox-gl.css'
78

89
export default {
910
...DefaultTheme,

auto-imports.d.ts

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,66 @@
66
// biome-ignore lint: disable
77
export {}
88
declare global {
9-
9+
const EffectScope: typeof import('vue')['EffectScope']
10+
const computed: typeof import('vue')['computed']
11+
const createApp: typeof import('vue')['createApp']
12+
const customRef: typeof import('vue')['customRef']
13+
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
14+
const defineComponent: typeof import('vue')['defineComponent']
15+
const effectScope: typeof import('vue')['effectScope']
16+
const getCurrentInstance: typeof import('vue')['getCurrentInstance']
17+
const getCurrentScope: typeof import('vue')['getCurrentScope']
18+
const h: typeof import('vue')['h']
19+
const inject: typeof import('vue')['inject']
20+
const isProxy: typeof import('vue')['isProxy']
21+
const isReactive: typeof import('vue')['isReactive']
22+
const isReadonly: typeof import('vue')['isReadonly']
23+
const isRef: typeof import('vue')['isRef']
24+
const markRaw: typeof import('vue')['markRaw']
25+
const nextTick: typeof import('vue')['nextTick']
26+
const onActivated: typeof import('vue')['onActivated']
27+
const onBeforeMount: typeof import('vue')['onBeforeMount']
28+
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
29+
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
30+
const onDeactivated: typeof import('vue')['onDeactivated']
31+
const onErrorCaptured: typeof import('vue')['onErrorCaptured']
32+
const onMounted: typeof import('vue')['onMounted']
33+
const onRenderTracked: typeof import('vue')['onRenderTracked']
34+
const onRenderTriggered: typeof import('vue')['onRenderTriggered']
35+
const onScopeDispose: typeof import('vue')['onScopeDispose']
36+
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
37+
const onUnmounted: typeof import('vue')['onUnmounted']
38+
const onUpdated: typeof import('vue')['onUpdated']
39+
const onWatcherCleanup: typeof import('vue')['onWatcherCleanup']
40+
const provide: typeof import('vue')['provide']
41+
const reactive: typeof import('vue')['reactive']
42+
const readonly: typeof import('vue')['readonly']
43+
const ref: typeof import('vue')['ref']
44+
const resolveComponent: typeof import('vue')['resolveComponent']
45+
const shallowReactive: typeof import('vue')['shallowReactive']
46+
const shallowReadonly: typeof import('vue')['shallowReadonly']
47+
const shallowRef: typeof import('vue')['shallowRef']
48+
const toRaw: typeof import('vue')['toRaw']
49+
const toRef: typeof import('vue')['toRef']
50+
const toRefs: typeof import('vue')['toRefs']
51+
const toValue: typeof import('vue')['toValue']
52+
const triggerRef: typeof import('vue')['triggerRef']
53+
const unref: typeof import('vue')['unref']
54+
const useAttrs: typeof import('vue')['useAttrs']
55+
const useCssModule: typeof import('vue')['useCssModule']
56+
const useCssVars: typeof import('vue')['useCssVars']
57+
const useId: typeof import('vue')['useId']
58+
const useModel: typeof import('vue')['useModel']
59+
const useSlots: typeof import('vue')['useSlots']
60+
const useTemplateRef: typeof import('vue')['useTemplateRef']
61+
const watch: typeof import('vue')['watch']
62+
const watchEffect: typeof import('vue')['watchEffect']
63+
const watchPostEffect: typeof import('vue')['watchPostEffect']
64+
const watchSyncEffect: typeof import('vue')['watchSyncEffect']
65+
}
66+
// for type re-export
67+
declare global {
68+
// @ts-ignore
69+
export type { Component, ComponentPublicInstance, ComputedRef, DirectiveBinding, ExtractDefaultPropTypes, ExtractPropTypes, ExtractPublicPropTypes, InjectionKey, PropType, Ref, MaybeRef, MaybeRefOrGetter, VNode, WritableComputedRef } from 'vue'
70+
import('vue')
1071
}

components.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ export {}
88
/* prettier-ignore */
99
declare module 'vue' {
1010
export interface GlobalComponents {
11+
ElButton: typeof import('element-plus/es')['ElButton']
12+
ElOption: typeof import('element-plus/es')['ElOption']
13+
ElSelect: typeof import('element-plus/es')['ElSelect']
1114
ElSwitch: typeof import('element-plus/es')['ElSwitch']
1215
}
1316
}

eslint.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export default antfu(
1414
'no-sequences': 'off',
1515
'perfectionist/sort-objects': 'off',
1616
'unused-imports/no-unused-vars': 'off',
17+
'antfu/top-level-function': 'off',
18+
'vue/html-self-closing': 'off',
1719
'vue/attributes-order': 'error',
1820
'vue/block-order': ['error', {
1921
order: ['template', 'script', 'style'],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"dependencies": {
3030
"element-plus": "^2.9.6",
31+
"mapbox-gl": "^3.10.0",
3132
"vue": "^3.5.13"
3233
},
3334
"devDependencies": {

packages/enums/mapbox.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export enum MapboxEnum {
2+
ACCESS_TOKEN = 'pk.eyJ1IjoiY29kZXJoeWgiLCJhIjoiY204ZDYwaTA1MDM0ajJqb2R4dXh5ZHlzZCJ9.rXI13A4HGl4TIvbtCjLblQ',
3+
}

packages/gis/mapbox/fly-to/demo.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<template>
2+
<div class="relative h-500px">
3+
<div class="absolute left-5px top-5px z-999 w200px">
4+
<el-button type="primary" @click="flyTo([121.5, 31.23])">
5+
To 上海
6+
</el-button>
7+
<el-button type="primary" @click="flyTo([116.46, 39.92])">
8+
To 北京
9+
</el-button>
10+
</div>
11+
<div ref="mapRef" class="h-100% w-100%" />
12+
</div>
13+
</template>
14+
15+
<script setup lang="ts">
16+
import mapboxgl from 'mapbox-gl'
17+
import { MapboxEnum } from '~/enums/mapbox'
18+
19+
mapboxgl.accessToken = MapboxEnum.ACCESS_TOKEN
20+
const mapRef = ref<HTMLDivElement>()
21+
const map = ref<mapboxgl.Map>()
22+
23+
const flyTo = (center: [number, number]) => {
24+
map.value?.flyTo({
25+
center,
26+
zoom: 10,
27+
speed: 1,
28+
})
29+
}
30+
31+
onMounted(() => {
32+
map.value = new mapboxgl.Map({
33+
container: mapRef.value!,
34+
style: 'mapbox://styles/mapbox/standard',
35+
center: [121.5, 31.23],
36+
projection: 'globe',
37+
zoom: 1,
38+
})
39+
})
40+
</script>

packages/gis/mapbox/fly-to/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# 点击飞行效果
2+
3+
:::preview 说明 || Mapbox 飞行效果
4+
5+
demo-preview=./demo.vue
6+
7+
:::

0 commit comments

Comments
 (0)