2024-11-07 17:14:01 +08:00
|
|
|
import AMapLoader from "@amap/amap-jsapi-loader";
|
|
|
|
|
|
|
|
type Amap = typeof AMap;
|
|
|
|
export const initMap = (plugins?: string[]): Promise<Amap> => new Promise((resolve, reject) => {
|
|
|
|
//@ts-ignore
|
|
|
|
window._AMapSecurityConfig = {
|
2024-11-08 11:47:04 +08:00
|
|
|
securityJsCode: __APP_ENV.VITE_APP_SECURITY_JS_CODE
|
2024-11-07 17:14:01 +08:00
|
|
|
}
|
|
|
|
AMapLoader.load({
|
|
|
|
key: __APP_ENV.VITE_APP_GAODE_KEY,
|
|
|
|
version: __APP_ENV.VITE_APP_GAODE_VERSION,
|
|
|
|
plugins
|
|
|
|
}).then((AMap: Amap) => {
|
|
|
|
resolve(AMap)
|
|
|
|
}).catch(err => {
|
|
|
|
reject(err)
|
|
|
|
})
|
|
|
|
})
|