webservice.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. import forOwn from 'lodash/forOwn';
  2. import isEqual from 'lodash/isEqual';
  3. import isNil from 'lodash/isNil';
  4. // M: Mandatory,必选
  5. // api调用限流说明: https://lbs.amap.com/api/webservice/guide/tools/flowlevel
  6. export const services = {
  7. // 地理/逆地理编码: https://lbs.amap.com/api/webservice/guide/api/georegeo
  8. geocode_geo: {
  9. name: '地理编码',
  10. method: 'GET',
  11. url: 'https://restapi.amap.com/v3/geocode/geo',
  12. parameters: {
  13. key:undefined, // M
  14. address:undefined, // M
  15. city:undefined, // M
  16. batch:false,
  17. sig:undefined,
  18. output:'JSON',
  19. callback: null
  20. }
  21. },
  22. geocode_regeo: {
  23. name: '逆地理编码',
  24. method: 'GET',
  25. url: 'https://restapi.amap.com/v3/geocode/regeo',
  26. parameters: {
  27. key:undefined, // M
  28. location:undefined, // M
  29. poitype:undefined,
  30. radius:1000,
  31. extensions:'base',
  32. batch:false,
  33. roadlevel:undefined,
  34. sig:undefined,
  35. output:'JSON',
  36. callback: null,
  37. homeorcorp:0
  38. }
  39. },
  40. // 路径规划: https://lbs.amap.com/api/webservice/guide/api/direction
  41. direction_walking: {
  42. name:'步行路径规划',
  43. method: 'GET',
  44. url: 'https://restapi.amap.com/v3/direction/walking',
  45. parameters: {
  46. key:undefined, // M
  47. origin:undefined, // M
  48. destination:undefined, // M
  49. sig:undefined,
  50. output:'JSON',
  51. callback: null,
  52. }
  53. },
  54. direction_transit_integrated: {
  55. name:'公交路径规划',
  56. method: 'GET',
  57. url: 'https://restapi.amap.com/v3/direction/transit/integrated',
  58. parameters: {
  59. key:undefined, // M
  60. }
  61. },
  62. direction_driving: {
  63. name:'驾车路径规划',
  64. method: 'GET',
  65. url: 'https://restapi.amap.com/v3/direction/driving',
  66. parameters: {
  67. key:undefined, // M
  68. }
  69. },
  70. direction_bicycling: {
  71. name:'骑行路径规划',
  72. method: 'GET',
  73. url: 'https://restapi.amap.com/v4/direction/bicycling',
  74. parameters: {
  75. key:undefined, // M
  76. }
  77. },
  78. direction_truck: {
  79. name:'货车路径规划',
  80. method: 'GET',
  81. url: 'https://restapi.amap.com/v4/direction/truck',
  82. parameters: {
  83. key:undefined, // M
  84. }
  85. },
  86. distance: {
  87. name:'距离测量',
  88. method: 'GET',
  89. url: 'https://restapi.amap.com/v3/distance',
  90. parameters: {
  91. key:undefined, // M
  92. }
  93. },
  94. // 行政区域查询: https://lbs.amap.com/api/webservice/guide/api/district
  95. config_district: {
  96. name:'行政区域查询',
  97. method: 'GET',
  98. url: 'https://restapi.amap.com/v3/config/district',
  99. parameters: {
  100. key:undefined, // M
  101. }
  102. },
  103. // 搜索POI: https://lbs.amap.com/api/webservice/guide/api/search
  104. place_text: {
  105. name:'关键字搜索',
  106. method: 'GET',
  107. url: 'https://restapi.amap.com/v3/place/text',
  108. parameters: {
  109. key:undefined, // M
  110. }
  111. },
  112. place_around: {
  113. name:'周边搜索',
  114. method: 'GET',
  115. url: 'https://restapi.amap.com/v3/place/around',
  116. parameters: {
  117. key:undefined, // M
  118. }
  119. },
  120. place_polygon: {
  121. name:'多边形搜索',
  122. method: 'GET',
  123. url: 'https://restapi.amap.com/v3/place/polygon',
  124. parameters: {
  125. key:undefined, // M
  126. }
  127. },
  128. place_detail: {
  129. name:'ID查询',
  130. method: 'GET',
  131. url: 'https://restapi.amap.com/v3/place/detail',
  132. parameters: {
  133. key:undefined, // M
  134. }
  135. },
  136. // IP定位: https://lbs.amap.com/api/webservice/guide/api/ipconfig
  137. ip: {
  138. name:'IP定位',
  139. method: 'GET',
  140. url: 'https://restapi.amap.com/v3/ip',
  141. parameters: {
  142. key:undefined, // M
  143. }
  144. },
  145. // 抓路服务: https://lbs.amap.com/api/webservice/guide/api/autograsp
  146. autograsp: {
  147. name:'抓路服务',
  148. method: 'GET',
  149. url: 'https://restapi.amap.com/v3/autograsp',
  150. parameters: {
  151. key:undefined, // M
  152. }
  153. },
  154. // 批量请求接口: https://lbs.amap.com/api/webservice/guide/api/batchrequest
  155. batch: {
  156. name:'批量请求接口',
  157. method: 'POST',
  158. url: 'https://restapi.amap.com/v3/batch',
  159. parameters: {
  160. key:undefined, // M
  161. },
  162. body: {
  163. "ops": [
  164. {
  165. "url": "/v3/place/around?offset=10&page=1&key=<您的key>&location=116.50394379585519,39.278209477408794&output=json&radius=100000&types=080000"
  166. },
  167. {
  168. "url": "/v3/place/around?offset=10&page=1&key=<您的key>&location=118.50394379585519,39.278209477408794&output=json&radius=100000&types=080000"
  169. }
  170. ]
  171. }
  172. },
  173. // 静态地图: https://lbs.amap.com/api/webservice/guide/api/staticmaps
  174. staticmap: {
  175. name:'静态地图',
  176. method: 'GET',
  177. url: 'https://restapi.amap.com/v3/staticmap',
  178. parameters: {
  179. key:undefined, // M
  180. },
  181. },
  182. // 坐标转换: https://lbs.amap.com/api/webservice/guide/api/convert
  183. assistant_coordinate_convert: {
  184. name:'坐标转换',
  185. method: 'GET',
  186. url: 'https://restapi.amap.com/v3/assistant/coordinate/convert',
  187. parameters: {
  188. key:undefined, // M
  189. },
  190. },
  191. // 天气查询: https://lbs.amap.com/api/webservice/guide/api/weatherinfo
  192. weather_weatherInfo: {
  193. name:'天气查询',
  194. method: 'GET',
  195. url: 'https://restapi.amap.com/v3/weather/weatherInfo',
  196. parameters: {
  197. key:undefined, // M
  198. },
  199. },
  200. // 输入提示: https://lbs.amap.com/api/webservice/guide/api/inputtips
  201. assistant_inputtips: {
  202. name:'输入提示',
  203. method: 'GET',
  204. url: 'https://restapi.amap.com/v3/assistant/inputtips',
  205. parameters: {
  206. key:undefined, // M
  207. },
  208. },
  209. // 交通态势: https://lbs.amap.com/api/webservice/guide/api/trafficstatus
  210. traffic_status_rectangle: {
  211. name: '矩形区域交通态势',
  212. method: 'GET',
  213. url: 'https://restapi.amap.com/v3/traffic/status/rectangle',
  214. parameters: {
  215. key:undefined, // M
  216. },
  217. },
  218. traffic_status_circle: {
  219. name: '圆形区域交通态势',
  220. method: 'GET',
  221. url: 'https://restapi.amap.com/v3/traffic/status/circle',
  222. parameters: {
  223. key:undefined, // M
  224. },
  225. },
  226. traffic_status_road: {
  227. name: '指定线路交通态势',
  228. method: 'GET',
  229. url: 'https://restapi.amap.com/v3/traffic/status/road',
  230. parameters: {
  231. key:undefined, // M
  232. },
  233. },
  234. // 地理围栏: https://lbs.amap.com/api/webservice/guide/api/geofence_service
  235. geofence_meta_post: {
  236. name: '创建围栏',
  237. method: 'POST',
  238. url: 'https://restapi.amap.com/v4/geofence/meta',
  239. parameters: {
  240. key:undefined, // M
  241. },
  242. body: {
  243. name: undefined //M
  244. }
  245. },
  246. geofence_meta_get: {
  247. name: '查询围栏',
  248. method: 'GET',
  249. url: 'https://restapi.amap.com/v4/geofence/meta',
  250. parameters: {
  251. key:undefined, // M
  252. },
  253. },
  254. geofence_meta_patch: {
  255. name: '更新围栏',
  256. method: 'POST ', // PATCH
  257. url: 'https://restapi.amap.com/v4/geofence/meta',
  258. parameters: {
  259. key:undefined, // M
  260. gid: undefined, // M
  261. method: undefined// 'patch'
  262. },
  263. body: {
  264. name: undefined, //M
  265. }
  266. },
  267. geofence_meta_patch2: {
  268. name: '围栏启动&停止',
  269. method: 'POST ', // PATCH
  270. url: 'https://restapi.amap.com/v4/geofence/meta',
  271. parameters: {
  272. key:undefined, // M
  273. gid: undefined, //M
  274. method: undefined //'patch'
  275. },
  276. body: {
  277. name: undefined, //M
  278. }
  279. },
  280. geofence_meta_delete: {
  281. name: '删除围栏',
  282. method: 'DELETE ', // POST
  283. url: 'https://restapi.amap.com/v4/geofence/meta',
  284. parameters: {
  285. key:undefined, // M
  286. gid: undefined, //M
  287. method: undefined, //'delete'
  288. },
  289. body: {
  290. name: undefined, //M
  291. }
  292. },
  293. geofence_status: {
  294. name: '围栏设备监控',
  295. method: 'GET',
  296. url: 'https://restapi.amap.com/v4/geofence/status',
  297. parameters: {
  298. key:undefined, // M
  299. diu:undefined, // M
  300. uid: undefined,
  301. locations: undefined, // M
  302. sig: undefined,
  303. },
  304. },
  305. // 轨迹纠偏: https://lbs.amap.com/api/webservice/guide/api/grasproad
  306. grasproad_driving: {
  307. name: '轨迹纠偏',
  308. method: 'POST',
  309. url: 'https://restapi.amap.com/v4/grasproad/driving',
  310. parameters: {
  311. key:undefined, // M
  312. },
  313. body: {
  314. x: undefined, // M
  315. y: undefined, // M
  316. ag: undefined, // M
  317. tm: undefined, // M
  318. sp: undefined // M
  319. }
  320. },
  321. }
  322. export const infocode = {
  323. "10000": {
  324. info: 'OK',
  325. desc: '请求正常',
  326. suggest: '请求正常'
  327. },
  328. "10001": {
  329. info: 'INVALID_USER_KEY',
  330. desc: 'key不正确或过期',
  331. suggest: '开发者发起请求时,传入的key不正确或者过期 '
  332. },
  333. "10002": {
  334. info: 'SERVICE_NOT_AVAILABLE',
  335. desc: '没有权限使用相应的服务或者请求接口的路径拼写错误',
  336. suggest: '1.开发者没有权限使用相应的服务,例如:开发者申请了WEB定位功能的key,却使用该key访问逆地理编码功能时,就会返回该错误。反之亦然。2.开发者请求接口的路径拼写错误。例如:正确的https://restapi.amap.com/v3/ip在程序中被拼装写了https://restapi.amap.com/vv3/ip"'
  337. },
  338. }