import AMapLoader from "@amap/amap-jsapi-loader";
import {MapPlugins} from "@/types/components/map";

export const initMap = (plugins?: MapPlugins[]): Promise<typeof AMap> => new Promise((resolve, reject) => {
    //@ts-ignore
    window._AMapSecurityConfig = {
        securityJsCode: __APP_ENV.VITE_APP_SECURITY_JS_CODE
    }
    AMapLoader.load({
        key: __APP_ENV.VITE_APP_GAODE_KEY,
        version: __APP_ENV.VITE_APP_GAODE_VERSION,
        plugins
    }).then((aMap: typeof AMap) => {
        resolve(aMap)
    }).catch(err => {
        reject(err)
    })
})
