/**
 * @description  地图加载
 * @author       朱琦
 * @date         2021/11/11 13:06
 */

import {initAMap, loadMapThemeConfig, mergeMapIconConfig, loadBusinessSdk} from './lib/init-map';
import {configureFetchConfig} from './lib/request';

import MvMap from "./components/MvMap";
import MvMapIcon from "./components/MvMapIcon";
import MvMapMenu from "./components/MvMapMenu";
import MvMapDialog from "./components/MvMapDialog";
import MvFocusCar from "./components/MvFocusCar";
import MvDialogDetail from "./components/MvDialogDetail";
// import MvMapLayer from "./components/MvMapLayer";

let components = [
    MvMap,
    MvMapIcon,
    MvMapMenu,
    MvMapDialog,
    MvFocusCar,
    MvDialogDetail
    // MvMapLayer
];

export default {

    install: (Vue, option = {}) => {

        /**
         * 初始化Map
         */
        initAMap(Vue, option.initMapConfig, option.mapUIConfig);

        /**
         * 加载MapUI配置
         */
        // loadMapUIConfig(option.mapUIConfig);

        /**
         * 加载Map主题配置
         */
        loadMapThemeConfig(option.themeConfig);

        /**
         * 加载Map图标配置
         */
        mergeMapIconConfig(option.mapIconConfig);

        /**
         * 配置业务图层请求地址
         */
        configureFetchConfig(option.fetchConfig)

        /**
         * 加载业务sdk
         */
        loadBusinessSdk(option.businessSdk)

        //组件注册
        components.map(_component => {
            // 组件注册
            Vue.component(_component.name, _component);
        });
    }
}
