Commit f2c505fc by 匡雅琴

修复

1 parent 2ae3083e
......@@ -186,7 +186,7 @@ export default {
initMap() {
let check = () => {
this.checkMapLoaded && window.clearTimeout(this.checkMapLoaded);
return this.$nextTick(() => {
return setTimeout(() => {
if (
"AMap" in window &&
typeof AMap.Map == "function" &&
......@@ -194,10 +194,8 @@ export default {
) {
window.AMap = AMap;
this.mapObj = mapService.init("map");
//this.bindEvent();
this.isInitMap = true;
this.getStayPointList(this.vehicleId)
// this.drawPoi()
} else {
this.checkMapLoaded = check();
}
......
......@@ -657,8 +657,6 @@ export default {
) {
window.AMap = AMap;
this.mapObj = mapService.init("map");
//this.bindEvent();
this.isInitMap = true;
if (this.$route.query.snArr) {
let routeQuery = JSON.parse(this.$route.query.snArr);
......
......@@ -270,73 +270,72 @@ MapService.prototype = {
fillOpacity: 1
});
},
// createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
// var infoWindow = new AMap.InfoWindow({
// offset: new AMap.Pixel(0, 0),
// content: div,
// autoMove: !!isInfoAutoMove
// });
// marker.infoWindow = infoWindow;
// // var clipboard = new ClipboardJS(div.querySelector('.copy-btn'));
// if (clipboard) {
// clipboard.destroy();
// }
// clipboard = new ClipboardJS('.copy-btn', {
// text: function(trigger) {
// return trigger.getAttribute('aria-label');
// }
// })
// clipboard.on('success', function(e) {
// e.clearSelection();
// EventBus.$emit('uiMap.copySuccess');
// });
// clipboard.on('error', function(e) {
// });
// if (isInfoOpen) {
// infoWindow.open(map, marker.getPosition());
// }
// //给Marker绑定单击事件
// marker.on('click', markerClick);
// function markerClick(e) {
// //infoWindow.setContent(e.target.content);
// infoWindow.open(map, e.target.getPosition());
// }
// return infoWindow;
// },
createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
var infoWindow = new AMap.InfoWindow({
offset: new AMap.Pixel(0, 0),
content: div,
autoMove: !!isInfoAutoMove,
})
marker.infoWindow = infoWindow
var clipboard = new ClipboardJS(div.querySelector('.copy-btn'))
clipboard.on('success', function (e) {
e.clearSelection()
EventBus.$emit('uiMap.copySuccess')
})
clipboard.on('error', function (e) {
console.error('Action:', e.action)
console.error('Trigger:', e.trigger)
offset: new AMap.Pixel(0, 0),
content: div,
autoMove: !!isInfoAutoMove
});
marker.infoWindow = infoWindow;
// var clipboard = new ClipboardJS(div.querySelector('.copy-btn'));
if (clipboard) {
clipboard.destroy();
}
clipboard = new ClipboardJS('.copy-btn', {
text: function(trigger) {
return trigger.getAttribute('aria-label');
}
})
clipboard.on('success', function(e) {
e.clearSelection();
EventBus.$emit('uiMap.copySuccess');
});
clipboard.on('error', function(e) {
});
if (isInfoOpen) {
infoWindow.open(map, marker.getPosition())
infoWindow.open(map, marker.getPosition());
}
//给Marker绑定单击事件
marker.on('click', markerClick)
marker.on('click', markerClick);
function markerClick(e) {
//infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition())
//infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition());
}
return infoWindow
},
return infoWindow;
},
// createInfoWindow(marker, map, div, isInfoOpen, isInfoAutoMove) {
// var infoWindow = new AMap.InfoWindow({
// offset: new AMap.Pixel(0, 0),
// content: div,
// autoMove: !!isInfoAutoMove,
// })
// marker.infoWindow = infoWindow
// var clipboard = new ClipboardJS(div.querySelector('.copy-btn'))
// clipboard.on('success', function (e) {
// e.clearSelection()
// EventBus.$emit('uiMap.copySuccess')
// })
// clipboard.on('error', function (e) {
// console.error('Action:', e.action)
// console.error('Trigger:', e.trigger)
// })
// if (isInfoOpen) {
// infoWindow.open(map, marker.getPosition())
// }
// //给Marker绑定单击事件
// marker.on('click', markerClick)
// function markerClick(e) {
// //infoWindow.setContent(e.target.content);
// infoWindow.open(map, e.target.getPosition())
// }
// return infoWindow
// },
// 初始化复制事件
initCopyEvent() {
var clipboard = new ClipboardJS('.copy-btn', {
......@@ -596,7 +595,15 @@ MapService.prototype = {
var self = this;
var infoDiv = document.createElement('div');
infoDiv.innerHTML = self.createLocationInfo(info);
// let addressCopyBtn = infoDiv.querySelector('[address-copy]');
let addressCopyBtn = new ClipboardJS(infoDiv.querySelector('.address-copy'));
console.log(addressCopyBtn, 'addressCopyBtn');
addressCopyBtn.on('success', function(e) {
e.clearSelection();
EventBus.$emit('uiMap.copySuccess');
});
addressCopyBtn.on('error', function(e) {
});
return this.createInfoWindow(marker, map, infoDiv);
},
bindResidentInfoWindow(marker, map, info) {
......@@ -862,7 +869,7 @@ MapService.prototype = {
<div class="map-infowindow-ct">
<p><i class="icon icon-info_time"></i> 停留时间: <span class="des">${info.begintime}</span></p>
<p><i class="icon icon-info_location"></i> 停留地址: <span class="des adr" >${info.transferAddress}</span>
<a class="copy-btn" data-clipboard-text="${info.transferAddress}"><i class="icon icon-info_copy"></i></a>
<a class="copy-btn address-copy" id="address-copy" address-copy data-clipboard-text="${info.transferAddress}"><i class="icon icon-info_copy"></i></a>
</p>
<p><i class="icon icon-info_stop"></i> 停留时长: <span class="des">${info.duration}</span></p>
</div>`;
......@@ -1029,7 +1036,7 @@ MapService.prototype = {
position: [info.lng, info.lat],
})
return infoWindow
}
},
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!