import { config as AmapReactConfig } from "@amap/amap-react";

AmapReactConfig.version = "2.0"; // 默认2.0，这里可以不修改
AmapReactConfig.key = "8de83e1728d5368f8452eee95f35585d";

// @ts-ignore
window._AMapSecurityConfig = {
  serviceHost: "https://sit-shgybwg.4dage.com/_AMapService",
};

/**
 * 修改高德地图 key
 * @param key JS-API key
 * @param serviceHost 安全密钥地址
 */
export const setAmapJSKey = (key: string, serviceHost?: string) => {
  AmapReactConfig.key = key;
  if (serviceHost) {
    // @ts-ignore
    window._AMapSecurityConfig = {
      serviceHost,
    };
  }
};
