(config: AppConfig | null, plugins: string[] = [])
| 53 | let amapPromise: Promise<any> | null = null; |
| 54 | |
| 55 | export function loadAmap(config: AppConfig | null, plugins: string[] = []) { |
| 56 | if (!config?.has_amap) { |
| 57 | return Promise.reject(new Error("高德 Key 未配置")); |
| 58 | } |
| 59 | window._AMapSecurityConfig = { |
| 60 | securityJsCode: config.amap_security_code, |
| 61 | }; |
| 62 | const existing = new Set<string>((window as any).__mapgameAmapPlugins || []); |
| 63 | const mergedPlugins = Array.from(new Set([...existing, ...plugins])); |
| 64 | amapPromise = AMapLoader.load({ |
| 65 | key: config.amap_key, |
| 66 | version: "2.0", |
| 67 | plugins: mergedPlugins, |
| 68 | }); |
| 69 | (window as any).__mapgameAmapPlugins = mergedPlugins; |
| 70 | return amapPromise; |
| 71 | } |
| 72 | |
| 73 | function bounds(cells: ChallengeCell[]) { |
| 74 | if (cells.length === 0) return null; |
no outgoing calls
no test coverage detected