From cd67e8a495b6ce41fcfbdc626011ddad6549a824 Mon Sep 17 00:00:00 2001 From: xianfuxing Date: Tue, 4 Sep 2018 11:16:30 +0800 Subject: [PATCH] # bug fixed sleep until map initial then exec driving search --- src/views/counter/map2.vue | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/views/counter/map2.vue b/src/views/counter/map2.vue index 22f29c9..7198afa 100644 --- a/src/views/counter/map2.vue +++ b/src/views/counter/map2.vue @@ -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()