From 1df71bdd7fc5b35be1447c9cc574bf610666f436 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期一, 14 四月 2025 19:13:11 +0800 Subject: [PATCH] SERVE_URL --- src/model/map/GaoDeMap.ts | 28 +++++++++++++++++----------- 1 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/model/map/GaoDeMap.ts b/src/model/map/GaoDeMap.ts index fa81daf..7901fa0 100644 --- a/src/model/map/GaoDeMap.ts +++ b/src/model/map/GaoDeMap.ts @@ -13,6 +13,8 @@ export type GaoDeMarkerOption = { icon: { url: string; + /** @description 閫変腑鏃剁殑鍥剧墖 */ + selectUrl?: string; size: number; }; click?: (e: any, labelMarker: AMap.LabelMarker) => void; @@ -57,21 +59,19 @@ } as Partial<AMap.MapOptions>, } as Partial<GaoDeMapOption>) as GaoDeMapOption; try { - this.AMap = await AMapLoader.load({ key: gaoDeOption.key, version: gaoDeOption.version, plugins: gaoDeOption.plugins, }); - + this.map = new this.AMap.Map(gaoDeOption.container, gaoDeOption.aMapOption); this.setStyle(); } catch (error) { // console.error(error); } } - constructor() { - } + constructor() {} private setStyle() { const container = this.map.getContainer() as any; @@ -110,8 +110,9 @@ const layer = new AMap.LabelsLayer(markerLayerOption.layerOpt); const { markerOpt } = markerLayerOption; + const { icon } = markerOpt; + const convertData = (dataList ?? []).map<AMap.LabelMarkerOptions>((item) => { - const { icon } = markerOpt; return { // name: '鑷彁鐐�9', position: item.position, @@ -145,18 +146,23 @@ }; }); - const markerList = convertData.map((item) => { const label = new AMap.LabelMarker(item); - - if (markerOpt.click) { - label.on('click', (e) => markerOpt.click(e, label)); - } + + label.on('click', (e) => { + if (icon.selectUrl) { + setTimeout(() => { + label.setIcon({ + image: icon.selectUrl, + }); + }, 30); + } + markerOpt.click?.(e, label); + }); return label; }); layer.add(markerList); this.map.add(layer); - } } -- Gitblit v1.9.3