在sdk里面找到 AMapWX.prototype.getWalkingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);wx.request({url:"https://restapi.amap.com/v3/direction/walking",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&a.success({paths:c.data.route.paths})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})}; 修改success部分 AMapWX.prototype.getWalkingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);wx.request({url:"https://restapi.amap.com/v3/direction/walking",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){if(c&&c.data&&c.data.route){a.success({paths:c.data.route.paths})}else{a.fail(c.data)}},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})}; 主要原因是接口返回statusCode为200,但是返回data里面没有route字段 [图片]
如何解决高德 SDK返回错误码回调函数捕捉不到的问题?调用高德微信小程序 SDK(代码如下),接口回调返回错误信息不进入success也不进入fail回调,询问高德技术人员,说微信小程序SDK后续不再维护,无法提供技术支持了,让我来问微信小程序开发。 var myAmapFun = new amapFile.AMapWX({ key: GAODE_API_KEY }); myAmapFun.getWalkingRoute({ origin: `${fromLng},${fromLat}`, destination: `${toLng},${toLat}`, success: function(data) {debugger handleSuccess(data, success, fail); }, fail: function(info) { debugger handleFail(info, fail); }, })
2023-09-04