This commit is contained in:
zk
2023-12-19 12:41:15 +08:00
parent 9b5be1af25
commit 5342774ca5
9 changed files with 50 additions and 39 deletions
+23 -12
View File
@@ -1,3 +1,4 @@
import AMapLoader from '@amap/amap-jsapi-loader';
import china from '/@/assets/lngLat/china.ts';
import chinaInner from '/@/assets/lngLat/chinaInner.ts';
import { createCircle, createIcon, typeToIcon } from '/@/assets/mapUtils/commonFun.ts';
@@ -11,6 +12,7 @@ export const defaultOption = {
mapStyle: 'darkblue', //地图样式
};
export const mapPlugin = ['AMap.ToolBar', 'AMap.Driving', 'AMap.GeoJSON', 'AMap.MarkerCluster', 'AMap.PlaceSearch'];
let AMap = null;
export const Map = {
map: null,
overlayGroup: null, // 地图中marker
@@ -25,18 +27,27 @@ export const Map = {
* @param option 地图配置
*/
initMap({ el, option }: InitMap) {
const { zoom, center, mapStyle } = { ...defaultOption, ...option };
//基本地图加载
this.map = new AMap.Map(el, {
resizeEnable: true,
center: center,
zoom: zoom,
mapStyle: 'amap://styles/' + mapStyle,
});
// 异步同时加载多个插件
new AMap.plugin(mapPlugin, () => {
this.drawInnerLine();
this.drawOutLine();
AMapLoader.load({
key: '4bbcb216b889f2d612cbed05ae6979c8', // 申请好的Web端开发者Key,首次调用 load 时必填
// version: '1.4.15', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: mapPlugin, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((res) => {
AMap = res;
const { zoom, center, mapStyle } = { ...defaultOption, ...option };
//基本地图加载
this.map = new AMap.Map(el, {
resizeEnable: true,
center: center,
zoom: zoom,
mapStyle: 'amap://styles/darkblue',
version: '2.0',
});
// 异步同时加载多个插件
new AMap.plugin(mapPlugin, () => {
this.drawInnerLine();
this.drawOutLine();
});
});
} /**
* @desc 中国外层边界线
@@ -61,7 +61,6 @@
const watchDialogRef = ref();
function openWatchList(item) {
console.log('item', item);
if (item.key == 'allotDeviceNum') {
watchDialogRef.value.openModal(item.extData?.deptId);
}
@@ -110,13 +109,13 @@
const { detailLeft, detailRight, setDetail } = useAlarmDetail();
onMounted(() => {
init();
//点击预警定位
$bus.on(earlyWarning, (params) => {
setDetail(params);
drawMarker(params);
setIsShowAlarm(true);
});
// init();
// //点击预警定位
// $bus.on(earlyWarning, (params) => {
// setDetail(params);
// drawMarker(params);
// setIsShowAlarm(true);
// });
});
/**
+2 -3
View File
@@ -1,4 +1,4 @@
import {createApp} from 'vue';
import { createApp } from 'vue';
import App from './App.vue';
import './assets/less/index.less';
import router from './router';
@@ -6,8 +6,7 @@ import router from './router';
import('ant-design-vue/dist/antd.less');
import registerGlobComp from './assets/ts/antd.ts';
import directiveMethods from './assets/ts/directive';
import {setupStore} from './store/index.ts';
import { setupStore } from './store/index.ts';
const app = createApp(App);
// 注册自定义事件