-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(map): added AMap/Baidu/Google Map example close #81
- Loading branch information
Showing
27 changed files
with
2,254 additions
and
127 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
- 图标选择器新增 svg 模式 | ||
- 新增时间组件 | ||
- 新增高德/百度/谷歌地图示例 | ||
|
||
### ✨ Refactor | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { resolve } from 'path'; | ||
import type { Alias } from 'vite'; | ||
|
||
function pathResolve(dir: string) { | ||
return resolve(__dirname, '.', dir); | ||
} | ||
|
||
export function createAlias(alias: [string, string][]): Alias[] { | ||
return alias.map((item) => { | ||
const [alia, src] = item; | ||
return { | ||
find: new RegExp(alia), | ||
replacement: pathResolve(src) + '/', | ||
}; | ||
}); | ||
} |
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
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
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,4 +1,7 @@ | ||
export default { | ||
baiduMap: '百度地图', | ||
aMap: '高德地图', | ||
googleMap: '谷歌地图', | ||
charts: '图表', | ||
map: '地图', | ||
line: '折线图', | ||
|
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<template> | ||
<div ref="wrapRef" :style="{ height, width }"></div> | ||
</template> | ||
<script lang="ts"> | ||
import { defineComponent, ref, nextTick, unref, onMounted } from 'vue'; | ||
import { useScript } from '/@/hooks/web/useScript'; | ||
const A_MAP_URL = 'https://webapi.amap.com/maps?v=2.0&key=d7bb98e7185300250dd5f918c12f484b'; | ||
export default defineComponent({ | ||
name: 'AMap', | ||
props: { | ||
width: { | ||
type: String, | ||
default: '100%', | ||
}, | ||
height: { | ||
type: String, | ||
default: 'calc(100vh - 78px)', | ||
}, | ||
}, | ||
setup() { | ||
const wrapRef = ref<HTMLDivElement | null>(null); | ||
const { toPromise } = useScript({ src: A_MAP_URL }); | ||
async function initMap() { | ||
await toPromise(); | ||
await nextTick(); | ||
const wrapEl = unref(wrapRef); | ||
if (!wrapEl) return; | ||
const AMap = (window as any).AMap; | ||
new AMap.Map(wrapEl, { | ||
zoom: 11, | ||
center: [116.397428, 39.90923], | ||
viewMode: '3D', | ||
}); | ||
} | ||
onMounted(() => { | ||
initMap(); | ||
}); | ||
return { wrapRef }; | ||
}, | ||
}); | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<template> | ||
<div ref="wrapRef" :style="{ height, width }"></div> | ||
</template> | ||
<script lang="ts"> | ||
import { defineComponent, ref, nextTick, unref, onMounted } from 'vue'; | ||
import { useScript } from '/@/hooks/web/useScript'; | ||
const BAI_DU_MAP_URL = | ||
'https://api.map.baidu.com/getscript?v=3.0&ak=OaBvYmKX3pjF7YFUFeeBCeGdy9Zp7xB2&services=&t=20210201100830'; | ||
export default defineComponent({ | ||
name: 'BaiduMap', | ||
props: { | ||
width: { | ||
type: String, | ||
default: '100%', | ||
}, | ||
height: { | ||
type: String, | ||
default: 'calc(100vh - 78px)', | ||
}, | ||
}, | ||
setup() { | ||
const wrapRef = ref<HTMLDivElement | null>(null); | ||
const { toPromise } = useScript({ src: BAI_DU_MAP_URL }); | ||
async function initMap() { | ||
await toPromise(); | ||
await nextTick(); | ||
const wrapEl = unref(wrapRef); | ||
if (!wrapEl) return; | ||
const BMap = (window as any).BMap; | ||
const map = new BMap.Map(wrapEl); | ||
const point = new BMap.Point(116.404, 39.915); | ||
map.centerAndZoom(point, 15); | ||
map.enableScrollWheelZoom(true); | ||
} | ||
onMounted(() => { | ||
initMap(); | ||
}); | ||
return { wrapRef }; | ||
}, | ||
}); | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<template> | ||
<div ref="wrapRef" :style="{ height, width }"></div> | ||
</template> | ||
<script lang="ts"> | ||
import { defineComponent, ref, nextTick, unref, onMounted } from 'vue'; | ||
import { useScript } from '/@/hooks/web/useScript'; | ||
const MAP_URL = | ||
'https://maps.googleapis.com/maps/api/js?key=AIzaSyBQWrrGwj4gAzKndcbwD5favT9K0wgty_0&signed_in=true'; | ||
export default defineComponent({ | ||
name: 'GoogleMap', | ||
props: { | ||
width: { | ||
type: String, | ||
default: '100%', | ||
}, | ||
height: { | ||
type: String, | ||
default: 'calc(100vh - 78px)', | ||
}, | ||
}, | ||
setup() { | ||
const wrapRef = ref<HTMLDivElement | null>(null); | ||
const { toPromise } = useScript({ src: MAP_URL }); | ||
async function initMap() { | ||
await toPromise(); | ||
await nextTick(); | ||
const wrapEl = unref(wrapRef); | ||
if (!wrapEl) return; | ||
const google = (window as any).google; | ||
const latLng = { lat: 116.404, lng: 39.915 }; | ||
const map = new google.maps.Map(wrapEl, { | ||
zoom: 4, | ||
center: latLng, | ||
}); | ||
new google.maps.Marker({ | ||
position: latLng, | ||
map: map, | ||
title: 'Hello World!', | ||
}); | ||
} | ||
onMounted(() => { | ||
initMap(); | ||
}); | ||
return { wrapRef }; | ||
}, | ||
}); | ||
</script> |
Oops, something went wrong.