diff --git a/src/assets/img/legend3.png b/src/assets/img/legend3.png index a63e980..ac05d52 100644 Binary files a/src/assets/img/legend3.png and b/src/assets/img/legend3.png differ diff --git a/src/assets/img/mapIcon1-1.png b/src/assets/img/mapIcon1-1.png index 8e9f179..41128d3 100644 Binary files a/src/assets/img/mapIcon1-1.png and b/src/assets/img/mapIcon1-1.png differ diff --git a/src/assets/img/mapIcon3.png b/src/assets/img/mapIcon3.png index fab6592..6ec8055 100644 Binary files a/src/assets/img/mapIcon3.png and b/src/assets/img/mapIcon3.png differ diff --git a/src/assets/mapUtils/commonFun.ts b/src/assets/mapUtils/commonFun.ts index da7e3bc..bc9ec40 100644 --- a/src/assets/mapUtils/commonFun.ts +++ b/src/assets/mapUtils/commonFun.ts @@ -47,7 +47,9 @@ export function typeToIcon1(type: string) { const iconSize = [21, 52]; const imageSize = [21, 52]; if (type == '1') { - return createIcon({ icon: mapIcon11, iconSize, imageSize }); + const iconS = [30, 65]; + const imageS = [30, 65]; + return createIcon({ icon: mapIcon11, iconSize: iconS, imageSize: imageS }); } if (type == '3') { return createIcon({ icon: mapIcon51, iconSize, imageSize }); @@ -61,7 +63,7 @@ export function typeToIcon1(type: string) { if (type === 'user') { const iconS = [36, 88]; const imageS = [36, 88]; - return createIcon({ icon: watchIconR, iconS, imageS }); + return createIcon({ icon: watchIconR, iconSize: iconS, imageSize: imageS }); } } diff --git a/src/assets/mapUtils/map.ts b/src/assets/mapUtils/map.ts index 449c1bd..8e5db10 100644 --- a/src/assets/mapUtils/map.ts +++ b/src/assets/mapUtils/map.ts @@ -24,6 +24,7 @@ export const Map = { endMarker: null, driving: null, walking: null, + mapDriverOrWalkLoading: false, /** * @desc 地图舒适化 * @param el dom元素 id选择器 @@ -213,7 +214,7 @@ export const Map = { if (computedCenter) { this.setZoomCenter(center, zoom); } - function createTextOverlayIcon(originalIconUrl, text, options = {}) { + function createTextOverlayIcon(originalIconUrl, text, type) { return new Promise((resolve) => { const canvas = document.createElement('canvas'); const ctx = canvas.getContext('2d'); @@ -221,14 +222,16 @@ export const Map = { img.crossOrigin = 'anonymous'; img.onload = function () { + const width = type == 1 ? 40 : 28; + const height = type == 1 ? 69 : 49; // 设置画布大小(比原图稍大以容纳文字) - canvas.width = 28; - canvas.height = 49 + 15; // 为文字留出空间 + canvas.width = width; + canvas.height = height + 15; // 为文字留出空间 // 绘制原始图标 - ctx.drawImage(img, 0, 10, 28, 49); + ctx.drawImage(img, 0, 10, width, height); // 绘制圆形文字背景 - const textX = 22; // 文字X坐标(居右对齐) + const textX = type == 1 ? 32 : 22; // 文字X坐标(居右对齐) const textY = 11; // 文字Y坐标 const textWidth = ctx.measureText(text).width; @@ -248,7 +251,7 @@ export const Map = { ctx.textAlign = 'right'; ctx.textBaseline = 'middle'; ctx.fillStyle = '#ffffff'; - ctx.fillText(text, 24.5, 10.8); + ctx.fillText(text, type == 1 ? 35 : 24.5, 10.8); resolve(canvas.toDataURL()); }; @@ -274,7 +277,7 @@ export const Map = { } // 创建一个 Icon const startIcon: any = typeToIcon(type); - const newIconUrl = await createTextOverlayIcon(startIcon, i + 1 + ''); + const newIconUrl = await createTextOverlayIcon(startIcon, i + 1 + '', result[i]?.type); // 将 icon 传入 marker const startMarker = new AMap.Marker({ // 点的坐标 @@ -613,6 +616,30 @@ export const Map = { }); }); }, + /** + * @desc 根据坐标获取地址信息 + * @param {Array} list 坐标点数组 + */ + getInfoByPoint(list: number[]) { + const geocoder = new AMap.Geocoder({ + city: '全国', + radius: 1000, + }); + let lnglat = new AMap.LngLat(list[0], list[1]); + return new Promise((resolve, reject) => { + geocoder.getAddress(lnglat, (status, result) => { + if (status === 'complete' && result.regeocode) { + let code = result?.regeocode?.addressComponent?.adcode; + code = code.substring(0, 4) + '00'; + if (code.substring(0, 3) !== '650') { + code = '650100'; + } + return resolve(code); + } + return reject(result); + }); + }); + }, /** * @desc 清除导航元素 */ diff --git a/src/components/dialog/Dialog.vue b/src/components/dialog/Dialog.vue index 04cda2b..28af297 100644 --- a/src/components/dialog/Dialog.vue +++ b/src/components/dialog/Dialog.vue @@ -7,6 +7,7 @@ :width="props.width" :maskClosable="true" @cancel="handleCancel" + v-bind="$attrs" destroy-on-close >