!159 地图组件新增卫星地图主题

Merge pull request !159 from tanhao/feat-map-theme
This commit is contained in:
奔跑的面条 2023-05-24 12:58:20 +00:00 committed by Gitee
commit adfd8c63e2
3 changed files with 15 additions and 3 deletions

View File

@ -16,7 +16,8 @@ export enum ThemeEnum {
MACARON = 'macaron',
BLUE = 'blue',
DARKBLUE = 'darkblue',
WINE = 'wine'
WINE = 'wine',
WEIXIN = 'tileLayer'
}
export enum LangEnum {

View File

@ -134,6 +134,10 @@ const themeOptions = [
{
value: ThemeEnum.WINE,
label: '酱籽'
},
{
value: ThemeEnum.WEIXIN,
label: '卫星'
}
]

View File

@ -8,7 +8,7 @@ import AMapLoader from '@amap/amap-jsapi-loader'
import { CreateComponentType } from '@/packages/index.d'
import { useChartDataFetch } from '@/hooks'
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
import { MarkerEnum } from './config'
import { MarkerEnum, ThemeEnum } from './config'
import { isArray } from '@/utils'
const props = defineProps({
@ -51,7 +51,6 @@ const initMap = (newData: any) => {
resizeEnable: true,
zoom: amapZindex.value, //
center: [amapLon.value, amapLat.value],
mapStyle: `amap://styles/${amapStyleKeyCustom.value !== '' ? amapStyleKeyCustom.value : amapStyleKey.value}`, //
lang: lang.value,
features: features.value,
pitch: pitch.value, // 0 - 83
@ -60,6 +59,14 @@ const initMap = (newData: any) => {
willReadFrequently: true
})
dataHandle(props.chartConfig.option.dataset)
let satellite = new AMap.TileLayer.Satellite()
let roadNet = new AMap.TileLayer.RoadNet()
if (newData.amapStyleKey === ThemeEnum.WEIXIN) {
mapIns.add([satellite, roadNet])
} else {
mapIns.remove([satellite, roadNet])
mapIns.setMapStyle(`amap://styles/${amapStyleKeyCustom.value !== '' ? amapStyleKeyCustom.value : amapStyleKey.value}`)
}
})
.catch(e => {})
}