| | |
| | | output: 'json' |
| | | } |
| | | }).then(res => { |
| | | if (res.data.info == 'OVER_DIRECTION_RANGE') { |
| | | this.$message({ |
| | | message: '超出步行范围!', |
| | | type: 'warning', |
| | | duration: 3000 |
| | | }) |
| | | } |
| | | |
| | | res.data.route.paths[0].steps.forEach(item => { |
| | | item.polyline = item.polyline.split(';') |
| | | |
| | |
| | | |
| | | routes += lineArr |
| | | }) |
| | | |
| | | console.log(routes, 123) |
| | | |
| | | routes = routes.substr(0, routes.length - 1) |
| | | |
| | |
| | | } else { |
| | | axios.get('https://restapi.amap.com/v3/direction/driving', { |
| | | params: { |
| | | origin: `${startLog + ',' + startLat}`, |
| | | destination: `${endLog + ',' + endLat}`, |
| | | origin: `${origin[0].toFixed(6) + ',' + origin[1].toFixed(6)}`, |
| | | destination: `${destination[0].toFixed(6) + ',' + destination[1].toFixed(6)}`, |
| | | key: '4b3e1db3211054ce5b466407cbb9d221', |
| | | strategy: 2, |
| | | extensions: 'all', |
| | |
| | | } |
| | | }).then(res => { |
| | | res.data.route.paths[0].steps.forEach(item => { |
| | | item.polyline += ';' |
| | | routes += item.polyline |
| | | item.polyline = item.polyline.split(';') |
| | | |
| | | var lineArr = [] |
| | | |
| | | item.polyline.forEach(it => { |
| | | it = it.split(',') |
| | | lineArr.push(this.DC.CoordTransform.GCJ02ToWGS84(it[0], it[1]).join(',')) |
| | | }) |
| | | |
| | | lineArr = lineArr.join(';') |
| | | |
| | | lineArr += ';' |
| | | |
| | | routes += lineArr |
| | | }) |
| | | |
| | | routes = routes.substr(0, routes.length - 1) |