This commit is contained in:
Smile-Xin 2025-02-17 17:25:11 +08:00
parent 5af24a0fce
commit 9064a35a94

View File

@ -102,6 +102,13 @@ class BaseMap extends React.Component {
this.getAllProvince();
this.createMap();
}
componentWillUnmount = () => {
// 组件卸载时,清除地图
this.state.map.map.destroy();
this.state.map.destroy();
this.setState = null;
console.log('组件卸载时,清除地图');
}
// 创建地图
createMap = () => {
const scene = new Scene({
@ -128,6 +135,7 @@ class BaseMap extends React.Component {
if (DistrictAdcode) {
this.onDistrictChange(DistrictAdcode, DistrictData);
}
// 地图拖拽鼠标图标更改
let can = document.getElementsByClassName('amap-layer')[0];
can.addEventListener('mousedown', (e) => {
console.log('mousedown', can);