utils.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { config as AmapReactConfig } from "@amap/amap-react";
  2. import { requestByGet } from "@dage/service";
  3. AmapReactConfig.version = "2.0"; // 默认2.0,这里可以不修改
  4. AmapReactConfig.key = "8de83e1728d5368f8452eee95f35585d";
  5. // @ts-ignore
  6. window._AMapSecurityConfig = {
  7. serviceHost: "https://sit-shgybwg.4dage.com/_AMapService",
  8. };
  9. /**
  10. * 修改高德地图 js-key
  11. * @param key JS-API key
  12. * @param serviceHost 安全密钥地址
  13. */
  14. export const setAmapJSKey = (key, serviceHost) => {
  15. AmapReactConfig.key = key;
  16. if (serviceHost) {
  17. // @ts-ignore
  18. window._AMapSecurityConfig = {
  19. serviceHost,
  20. };
  21. }
  22. };
  23. /**
  24. * 提供根据用户输入的关键词查询返回建议列表
  25. * @link https://lbs.amap.com/api/webservice/guide/api/inputtips
  26. * @param value
  27. * @param city 搜索城市
  28. * @param citylimit 是否限制城市搜索 默认-true
  29. * @returns
  30. */
  31. export const getAmapInputTips = (path, value, city, citylimit = "true") => {
  32. return requestByGet(path, {
  33. keywords: value,
  34. city,
  35. citylimit,
  36. });
  37. };