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