amap.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. let amapFile = require("./amap-wx");
  2. // 高德开发者key
  3. let key = '2ff0325d74a2d6edbdaf5338cc4eb37f';
  4. let myAmapFun = new amapFile.AMapWX({
  5. key
  6. });
  7. class Amap {
  8. /**
  9. * 获取POI数据
  10. * @param {string} querykeywords
  11. */
  12. static getPoiAround(querykeywords = '', location = '') {
  13. //console.log({
  14. // querykeywords,
  15. // location
  16. // });
  17. return new Promise((resolve, reject) => myAmapFun.getPoiAround({
  18. querykeywords,
  19. success: resolve,
  20. fail: reject,
  21. location
  22. }));
  23. }
  24. /**
  25. * 获取地理描述数据
  26. */
  27. static getRegeo() {
  28. return new Promise((resolve, reject) => myAmapFun.getRegeo({
  29. success: resolve,
  30. fail: reject
  31. }));
  32. }
  33. /**
  34. * 获取天气数据
  35. *
  36. */
  37. static getWeather() {
  38. return new Promise((resolve, reject) => myAmapFun.getWeather({
  39. success: resolve,
  40. fail: reject
  41. }));
  42. }
  43. /**
  44. * 获取输入提示词
  45. * @param {string} keywords
  46. * @param {string} location
  47. */
  48. static getInputtips(city, location = '', keywords = '') {
  49. return new Promise((resolve, reject) => myAmapFun.getInputtips({
  50. keywords,
  51. location,
  52. city,
  53. success: resolve,
  54. fail: reject
  55. }));
  56. }
  57. /**
  58. * 获取路线规划
  59. * type : getDrivingRoute --驾车
  60. * type : getWalkingRoute --步行
  61. * type : getTransitRoute --公交
  62. * type : getRidingRoute --骑行
  63. * @param {string} origin
  64. * @param {string} destination
  65. */
  66. static getRoute(origin, destination, type, city) {
  67. return new Promise((resolve, reject) => myAmapFun[type]({
  68. origin,
  69. destination,
  70. city,
  71. success: resolve,
  72. fail: reject
  73. }));
  74. }
  75. }
  76. module.exports = Amap;