# bug fixed sleep until map initial then exec driving search

This commit is contained in:
xianfuxing 2018-09-04 11:16:30 +08:00
parent 51e4259fd8
commit cd67e8a495
1 changed files with 5 additions and 0 deletions

View File

@ -73,6 +73,9 @@ export default {
}
},
methods: {
sleep(time) {
for (var temp = Date.now(); Date.now() - temp <= time;);
},
initMap() {
this.map = new AMap.Map('map-container', {
center: [114.143472, 22.284105],
@ -171,6 +174,7 @@ export default {
// cityd:'',
// policy: AMap.DrivingPolicy.LEAST_TIME
}
this.sleep(500)
const button = document.getElementById('bt')
AMap.plugin(['AMap.ToolBar', 'AMap.Scale', 'AMap.Driving'], () => {
map.addControl(new AMap.ToolBar())
@ -203,6 +207,7 @@ export default {
mounted() {
if (this.mapClick) {
const device_id = this.$store.getters.deviceID
// this.sleep(2000)
this.getDevicesInitMap({ device_id })
} else {
this.initMap()