Browse Source

地图销毁修改

release_0.0.4
‘lijianhao’ 2 years ago
parent
commit
78fefd2e70
  1. 12
      web/client/src/sections/quanju/containers/example.js

12
web/client/src/sections/quanju/containers/example.js

@ -25,9 +25,9 @@ const Example = (props) => {
useEffect(() => { useEffect(() => {
const map = new AMap.Map("amapId", { const map = new AMap.Map("amapId", {
//resizeEnable: true, //resizeEnable: true,
center: [115.880421, 28.529637],//地图中心点,初始定位加载显示楼块 center: [115.912663, 28.543149],//地图中心点,初始定位加载显示楼块
// center: [115.857952, 28.683003],//地图中心点 // center: [115.857952, 28.683003],//地图中心点
zoom: 8,//地图显示的缩放级别 zoom: 13,//地图显示的缩放级别
zooms: [8, 18], zooms: [8, 18],
pitch: 65, // 地图俯仰角度,有效范围 0 度- 83 度 pitch: 65, // 地图俯仰角度,有效范围 0 度- 83 度
viewMode: '3D', // 地图模式 viewMode: '3D', // 地图模式
@ -45,9 +45,11 @@ const Example = (props) => {
window.onload = function () { window.onload = function () {
windowOnload = true; windowOnload = true;
} }
return () =>{ return () => {
map.destroy(); //销毁地图 const amapKeys = Object.keys(localStorage).filter(key => key.match(/^_AMap_/)) // 销毁地图
map=null amapKeys.forEach(key => {
localStorage.removeItem(key)
})
} }
}, []) }, [])

Loading…
Cancel
Save