amap.js 1.8 KB

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