2024-11-15 15:35:05 +08:00
|
|
|
import AMapLoader from "@amap/amap-jsapi-loader";
|
2024-11-15 17:06:59 +08:00
|
|
|
import { MapPlugins } from "@/types/components/map/index";
|
2024-11-15 15:35:05 +08:00
|
|
|
|
|
|
|
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)
|
|
|
|
})
|
|
|
|
})
|