Files
xj-screen/src/assets/mapUtils/commonFun.ts
T

59 lines
1.5 KiB
TypeScript

import { mapIcon1, mapIcon2, mapIcon3, mapIcon4 } from '/@/components/chinaMap/chinaHooks.ts';
/**
* @desc 创建icon
* */
export function createIcon({ icon, iconSize, imageSize }) {
return new AMap.Icon({
// 图标尺寸
size: new AMap.Size(...iconSize),
// 图标的取图地址
image: icon,
// 图标所用图片大小
imageSize: new AMap.Size(...imageSize),
});
}
/**
* @desc 根据类型创建Icon
* @type 1:油田医院,2:合作医院,3:医疗点
*/
export function typeToIcon(type: string) {
const iconSize = [18, 44];
const imageSize = [18, 44];
if (type == '1') {
return createIcon({ icon: mapIcon1, iconSize, imageSize });
}
if (type == '2') {
return createIcon({ icon: mapIcon4, iconSize, imageSize });
}
if (type == '3') {
return createIcon({ icon: mapIcon2, iconSize, imageSize });
}
if (type == '4') {
return createIcon({ icon: mapIcon3, iconSize, imageSize });
}
}
/**
*
*/
export function createCircle(option) {
const { lon, lat } = option;
return new AMap.Circle({
center: [lon, lat],
radius: 100000, //半径
borderWeight: 3,
strokeColor: '#FF33FF',
strokeOpacity: 1,
// strokeWeight: 6,
strokeOpacity: 0.2,
fillOpacity: 0.4,
strokeStyle: 'dashed',
strokeDasharray: [10, 10],
// 线样式还支持 'dashed'
fillColor: '#1791fc',
zIndex: 50,
...option,
});
}