update
1.新疆大屏新需求
This commit is contained in:
+43
-13
@@ -1,8 +1,8 @@
|
||||
import AMapLoader from '@amap/amap-jsapi-loader';
|
||||
import china from '/@/assets/lngLat/china.ts';
|
||||
import chinaInner from '/@/assets/lngLat/chinaInner.ts';
|
||||
import { createCircle, createIcon, getCenter, getLonLat, typeToIcon } from '/@/assets/mapUtils/commonFun.ts';
|
||||
import { aircraftContent, alarmIcon, female, male } from '/@/components/chinaMap/chinaHooks.ts';
|
||||
import { createCircle, createIcon, getCenter, getLonLat, typeToIcon, typeToIcon1 } from '/@/assets/mapUtils/commonFun.ts';
|
||||
import { aircraftContent, alarmIcon, female, male, watchIconR } from '/@/components/chinaMap/chinaHooks.ts';
|
||||
import { isFunction } from '/@/utils/is.ts';
|
||||
import { Callback, ExtDataType, InitMap, MarkerOption, ResultType } from '/@/assets/mapUtils/mapFunTypes.ts';
|
||||
import { defaultOption, getZoom, mapKey, mapPlugin } from '/@/assets/mapUtils/mapConstant.ts';
|
||||
@@ -139,15 +139,16 @@ export const Map = {
|
||||
* @param callback
|
||||
* @param computedCenter 是否计算中心点
|
||||
*/
|
||||
createOverlay(result: ResultType[], extData?: ExtDataType, callback?: Callback, computedCenter?: boolean) {
|
||||
createOverlay(result: ResultType[], extData?: ExtDataType, callback?: Callback, computedCenter?: boolean, iconType?: string) {
|
||||
this.removeOverlayGroup();
|
||||
this.overlayGroup = new AMap.OverlayGroup();
|
||||
let list = getLonLat(result);
|
||||
let center = getCenter(list);
|
||||
let zoom = getZoom(list);
|
||||
const list: any[] = getLonLat(result);
|
||||
const center = getCenter(list);
|
||||
const zoom = getZoom(list);
|
||||
if (computedCenter) {
|
||||
this.setZoomCenter(center, zoom);
|
||||
}
|
||||
let arr = [];
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
let { type, lon, lat, longitude, latitude, lng, centerResource } = result[i];
|
||||
|
||||
@@ -164,7 +165,7 @@ export const Map = {
|
||||
continue;
|
||||
}
|
||||
// 创建一个 Icon
|
||||
let startIcon = typeToIcon(type, centerResource);
|
||||
let startIcon = iconType === '1' ? typeToIcon(type) : typeToIcon1(type);
|
||||
// 将 icon 传入 marker
|
||||
let startMarker = new AMap.Marker({
|
||||
// 点的坐标
|
||||
@@ -179,6 +180,7 @@ export const Map = {
|
||||
},
|
||||
...extData?.extOption,
|
||||
});
|
||||
arr.push(startMarker);
|
||||
// 可以调用setExtData()设置自定义属性
|
||||
//将组 挂载到地图上
|
||||
this.overlayGroup.setMap(this.map);
|
||||
@@ -191,6 +193,7 @@ export const Map = {
|
||||
if (!isFunction(callback)) return;
|
||||
callback(e.target.getExtData());
|
||||
});
|
||||
return arr;
|
||||
},
|
||||
clearOverlay() {
|
||||
if (this.overlayGroup) {
|
||||
@@ -374,6 +377,32 @@ export const Map = {
|
||||
});
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @desc 计算两个坐标点的步行时间
|
||||
* @param {Array} listA 坐标点数组
|
||||
* @param {Array} listB 坐标点数组
|
||||
* @param {Function} callback 回调
|
||||
* @return {Number} 时间
|
||||
*/
|
||||
getWalkingTime(listA: number[], listB: number[], callback?: Callback) {
|
||||
let lnglatA = new AMap.LngLat(listA[0], listA[1]);
|
||||
let lnglatB = new AMap.LngLat(listB[0], listB[1]);
|
||||
const drivingOptions = {
|
||||
policy: AMap.DrivingPolicy.LEAST_TIME,
|
||||
};
|
||||
let walking = new AMap.Walking(drivingOptions);
|
||||
return new Promise((resolve, reject) => {
|
||||
walking.search(lnglatA, lnglatB, (status, result) => {
|
||||
if (status === 'complete') {
|
||||
// console.log('result', result);
|
||||
if (callback && isFunction(callback)) {
|
||||
callback(result);
|
||||
}
|
||||
return resolve(result.routes[0]);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @desc 创建导航轨迹线路
|
||||
@@ -433,21 +462,22 @@ export const Map = {
|
||||
const icon = sex == '1' ? female : male;
|
||||
this.emergencyMarker = new AMap.Marker({
|
||||
position: position,
|
||||
icon: createIcon({ icon: icon, iconSize: [36, 36], imageSize: [36, 36] }),
|
||||
offset: new AMap.Pixel(0, 0), //设置偏移量
|
||||
icon: createIcon({ icon: watchIconR, iconSize: [80, 80], imageSize: [80, 80] }),
|
||||
offset: new AMap.Pixel(-40, -40), //设置偏移量
|
||||
label: {
|
||||
content: `<div class="alarm-content" style="width: 180px" >
|
||||
content: `<div class="alarm-content" style="width: 180px;z-index: 99" >
|
||||
<div style="text-align: center;padding-bottom: 6px">${name}</div>
|
||||
<div style="text-wrap: wrap">${address}</div>
|
||||
</div>`,
|
||||
offset: new AMap.Pixel(-100, 55),
|
||||
offset: new AMap.Pixel(-120, -70),
|
||||
},
|
||||
});
|
||||
this.map.add(this.emergencyMarker);
|
||||
this.setZoomCenter(position);
|
||||
// this.setZoomCenter(position);
|
||||
},
|
||||
/**
|
||||
* @desc 清除应急人员Marker
|
||||
* @desc 清除应急人员Marker..
|
||||
*
|
||||
*/
|
||||
clearEmergencyMarker() {
|
||||
if (this.emergencyMarker) {
|
||||
|
||||
Reference in New Issue
Block a user