diff --git a/web/client/src/sections/quanju/containers/example.js b/web/client/src/sections/quanju/containers/example.js index d5993a86..986938d7 100644 --- a/web/client/src/sections/quanju/containers/example.js +++ b/web/client/src/sections/quanju/containers/example.js @@ -23,33 +23,38 @@ const Example = (props) => { useEffect(() => { - const map = new AMap.Map("amapId", { - //resizeEnable: true, - center: [115.912663, 28.543149],//地图中心点,初始定位加载显示楼块 - // center: [115.857952, 28.683003],//地图中心点 - zoom: 13,//地图显示的缩放级别 - zooms: [8, 18], - pitch: 65, // 地图俯仰角度,有效范围 0 度- 83 度 - viewMode: '3D', // 地图模式 - // rotation: 60 - // showLabel: false - }); + + const timer = setTimeout(() => { + const map = new AMap.Map("amapId", { + //resizeEnable: true, + center: [115.912663, 28.543149],//地图中心点,初始定位加载显示楼块 + // center: [115.857952, 28.683003],//地图中心点 + zoom: 13,//地图显示的缩放级别 + zooms: [8, 18], + pitch: 65, // 地图俯仰角度,有效范围 0 度- 83 度 + viewMode: '3D', // 地图模式 + // rotation: 60 + // showLabel: false + }); + let styleName = 'amap://styles/fb26776387242721c2fc32e2cb1daccc'; + map.setMapStyle(styleName); + + let mapComplete = false; + let windowOnload = false; + window.onload = function () { + windowOnload = true; + } + }, 100); //主题样式 - let styleName = 'amap://styles/fb26776387242721c2fc32e2cb1daccc'; - map.setMapStyle(styleName); - - let mapComplete = false; - let windowOnload = false; - window.onload = function () { - windowOnload = true; - } + return () => { const amapKeys = Object.keys(localStorage).filter(key => key.match(/^_AMap_/)) // 销毁地图 amapKeys.forEach(key => { localStorage.removeItem(key) }) + clearTimeout(timer) } }, [])