19 lines
579 B
TypeScript
19 lines
579 B
TypeScript
import AMapLoader from "@amap/amap-jsapi-loader";
|
|
import { MapPlugins } from "@/types/components/map/index";
|
|
|
|
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)
|
|
})
|
|
})
|