|
@@ -133,27 +133,15 @@
|
|
|
const _this = this
|
|
|
_this.polyline = []
|
|
|
// 将所有标注点都按距离进行路线规划
|
|
|
- _this.distanceMark.map((item,index) => {
|
|
|
- var position = null
|
|
|
- if(index==0){
|
|
|
- position = [
|
|
|
- { latitude: _this.latitude, longitude: _this.longitude },
|
|
|
- { latitude: item.latitude, longitude: item.longitude }
|
|
|
- ]
|
|
|
- // 当前位置到第一个标注点的路线规划
|
|
|
- _this.getDirection(position)
|
|
|
- }else{
|
|
|
- position = [
|
|
|
- { latitude: _this.distanceMark[index-1].latitude, longitude: _this.distanceMark[index-1].longitude },
|
|
|
- { latitude: item.latitude, longitude: item.longitude }
|
|
|
- ]
|
|
|
- // 第index-1个标注点到第index个标注点的路线规划
|
|
|
- _this.getDirection(position)
|
|
|
- }
|
|
|
- })
|
|
|
+ var position = null
|
|
|
+ position = [
|
|
|
+ { latitude: _this.latitude, longitude: _this.longitude },
|
|
|
+ { latitude: _this.distanceMark[0].latitude, longitude: _this.distanceMark[0].longitude }
|
|
|
+ ]
|
|
|
+ _this.getDirection(position, 0)
|
|
|
},
|
|
|
// 路线规划
|
|
|
- getDirection(position){
|
|
|
+ getDirection(position, ind){
|
|
|
const _this = this
|
|
|
qqmapsdk.direction({
|
|
|
mode: 'driving',//可选值:'driving'(驾车)、'walking'(步行)、'bicycling'(骑行),不填默认:'driving',可不填
|
|
@@ -190,7 +178,23 @@
|
|
|
console.error(error)
|
|
|
},
|
|
|
complete: function (res) {
|
|
|
- // console.log(res)
|
|
|
+ // 腾讯地图使用限制
|
|
|
+ // 为了保证我们的服务稳定,我们对每个key的每个服务接口的调用量做了如下限制:
|
|
|
+ // 日调用量:1万次 / Key
|
|
|
+ // 并发数:5次 / key / 秒
|
|
|
+
|
|
|
+ // 递归调用避免并发限制
|
|
|
+ if(ind < _this.distanceMark.length-1){
|
|
|
+ let pos = [
|
|
|
+ { latitude: _this.distanceMark[ind].latitude, longitude: _this.distanceMark[ind].longitude },
|
|
|
+ { latitude: _this.distanceMark[ind+1].latitude, longitude: _this.distanceMark[ind+1].longitude }
|
|
|
+ ]
|
|
|
+ let subInd = ind
|
|
|
+ subInd++
|
|
|
+ setTimeout(()=>{
|
|
|
+ _this.getDirection(pos, subInd)
|
|
|
+ },300)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|