19 lines
527 B
TypeScript
19 lines
527 B
TypeScript
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 = {
|
|
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: Amap) => {
|
|
resolve(AMap)
|
|
}).catch(err => {
|
|
reject(err)
|
|
})
|
|
})
|