| | |
| | | <template> |
| | | <div class="relative"> |
| | | <HeaderBox /> |
| | | <div id="mapcontainer" style="width: 1920px; height: 995px"></div> |
| | | <div id="container" style="width: 1920px; height: 995px"></div> |
| | | <!-- 类型切换tab --> |
| | | <div |
| | | class="flex a-center absolute postion-center top--109 br--16 c-fff fs--14 bgcolor4 SSHR" |
| | | > |
| | |
| | | 占位盒子 |
| | | </div> |
| | | </div> |
| | | <!-- 左下角隐患 --> |
| | | <div class="flex a-center absolute left--14 bottom--14"> |
| | | <img |
| | | src="../../assets/img/home/Group@2x (4).png" |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <!-- 地图legend --> |
| | | <div |
| | | class="absolute bottom0 h--120 w--250 py--29 px--37 bgimg5" |
| | | class="absolute bottom--30 h--120 w--250 py--29 px--37 bgimg5" |
| | | style="right: 505px" |
| | | > |
| | | <div class="flex a-center j-between fs--12 SHSR c-fff"> |
| | | <div class="flex a-center gap--14 cursor-pointer"> |
| | | <div |
| | | class="flex a-center gap--14 cursor-pointer" |
| | | @click="toggleCategory('municipal')" |
| | | > |
| | | <img |
| | | src="../../assets/img/home/Combined Shape@2x.png" |
| | | class="w--16 h--16 shrink0" |
| | | /> |
| | | <div>市政</div> |
| | | </div> |
| | | <div class="flex a-center gap--14 cursor-pointer"> |
| | | <div |
| | | class="flex a-center gap--14 cursor-pointer" |
| | | @click="toggleCategory('house')" |
| | | > |
| | | <img |
| | | src="../../assets/img/home/Shape@2x (4).png" |
| | | class="w--18 h--16 shrink0" |
| | |
| | | </div> |
| | | </div> |
| | | <div class="flex a-center j-between gap--23 px--13 fs--12 SHSR mt--26"> |
| | | <div class="flex a-center flex-column cursor-pointer"> |
| | | <div |
| | | class="flex a-center flex-column cursor-pointer" |
| | | @click="toggleLevel('A')" |
| | | > |
| | | <div class="w--8 h--8 mb--5 br50 bgcolor8"></div> |
| | | <div class="color8">A类</div> |
| | | </div> |
| | | <div class="flex a-center flex-column cursor-pointer"> |
| | | <div |
| | | class="flex a-center flex-column cursor-pointer" |
| | | @click="toggleLevel('B')" |
| | | > |
| | | <div class="w--8 h--8 mb--5 br50 bgcolor9"></div> |
| | | <div class="color9">B类</div> |
| | | </div> |
| | | <div class="flex a-center flex-column cursor-pointer"> |
| | | <div |
| | | class="flex a-center flex-column cursor-pointer" |
| | | @click="toggleLevel('C')" |
| | | > |
| | | <div class="w--8 h--8 mb--5 br50 bgcolor10"></div> |
| | | <div class="color10">C类</div> |
| | | </div> |
| | |
| | | </template> |
| | | </TitleBox> |
| | | </div> |
| | | <div class="mt--25"> |
| | | <div class="mt--25" v-if="activeTab == 1"> |
| | | <TitleBox> |
| | | <template #title> 设备数据总览 </template> |
| | | <template #content> |
| | |
| | | </template> |
| | | </TitleBox> |
| | | </div> |
| | | |
| | | <div class="mt--33"> |
| | | <TitleBox> |
| | | <template #title> 工作展示 </template> |
| | |
| | | <script> |
| | | import HeaderBox from "../header/index.vue"; |
| | | import moment from "moment"; |
| | | import s1 from "../../assets/img/home/s1.png"; |
| | | import s2 from "../../assets/img/home/s2.png"; |
| | | import s3 from "../../assets/img/home/s3.png"; |
| | | import f1 from "../../assets/img/home/f1.png"; |
| | | import f2 from "../../assets/img/home/f2.png"; |
| | | import f3 from "../../assets/img/home/f3.png"; |
| | | export default { |
| | | components: { |
| | | HeaderBox, |
| | |
| | | scrollContainer: null, // 滚动容器引用 |
| | | activeIndex: 0, // 当前活动索引 |
| | | projectId: null, |
| | | categoryFilter: { |
| | | municipal: true, |
| | | house: true, |
| | | }, |
| | | levelFilter: { |
| | | A: true, |
| | | B: true, |
| | | C: true, |
| | | }, |
| | | markers: [], |
| | | }; |
| | | }, |
| | | watch: { |
| | |
| | | event.preventDefault(); |
| | | this.scrollContainer.scrollTop += event.deltaY; |
| | | }, |
| | | |
| | | setMapload() { |
| | | AMapLoader.load({ |
| | | key: "232929db1cb31f26d42b3645a7456154", //申请好的Web端开发者 Key,调用 load 时必填 |
| | | version: "2.0", //指定要加载的 JS API 的版本,缺省时默认为 1.4.15 |
| | | key: "232929db1cb31f26d42b3645a7456154", |
| | | version: "2.0", |
| | | }) |
| | | .then((AMap) => { |
| | | this.mapView = new AMap.Map("mapcontainer", { |
| | | // resizeEnable: true, //是否监控地图容器尺寸变化 |
| | | // 微信建筑图层 |
| | | let satellite = new AMap.TileLayer.Satellite(); |
| | | //创建路网图层 |
| | | let roadNet = new AMap.TileLayer.RoadNet(); |
| | | this.mapView = new AMap.Map("container", { |
| | | zoom: 13, |
| | | center: [108.357471, 22.828643], // 初始化地图中心点 |
| | | mapStyle: "amap://styles/darkblue", |
| | | // layers: [satellite], |
| | | }); |
| | | this.mapView.on("click", (e) => {}); |
| | | this.initCategoryMarkers(AMap); |
| | | }) |
| | | .catch((e) => { |
| | | console.error(e); //加载错误提示 |
| | | }); |
| | | }, |
| | | initCategoryMarkers(AMap) { |
| | | if (!this.mapView) { |
| | | return; |
| | | } |
| | | const points = [ |
| | | { |
| | | position: [108.357471, 22.828643], |
| | | category: "municipal", |
| | | level: "A", |
| | | }, |
| | | { |
| | | position: [108.367471, 22.828643], |
| | | category: "municipal", |
| | | level: "B", |
| | | }, |
| | | { |
| | | position: [108.347471, 22.828643], |
| | | category: "municipal", |
| | | level: "C", |
| | | }, |
| | | { |
| | | position: [108.357471, 22.838643], |
| | | category: "house", |
| | | level: "A", |
| | | }, |
| | | { |
| | | position: [108.367471, 22.838643], |
| | | category: "house", |
| | | level: "B", |
| | | }, |
| | | { |
| | | position: [108.347471, 22.838643], |
| | | category: "house", |
| | | level: "C", |
| | | }, |
| | | ]; |
| | | const markers = []; |
| | | points.forEach((item) => { |
| | | const marker = this.createCategoryMarker(AMap, item); |
| | | if (marker) { |
| | | this.mapView.add(marker); |
| | | markers.push(marker); |
| | | } |
| | | }); |
| | | this.markers = markers; |
| | | this.updateMarkerVisibility(); |
| | | }, |
| | | createCategoryMarker(AMap, item) { |
| | | if (!item || !item.position) { |
| | | return null; |
| | | } |
| | | let image = null; |
| | | if (item.category === "municipal") { |
| | | if (item.level === "A") { |
| | | image = s1; |
| | | } else if (item.level === "B") { |
| | | image = s2; |
| | | } else if (item.level === "C") { |
| | | image = s3; |
| | | } |
| | | } else if (item.category === "house") { |
| | | if (item.level === "A") { |
| | | image = f1; |
| | | } else if (item.level === "B") { |
| | | image = f2; |
| | | } else if (item.level === "C") { |
| | | image = f3; |
| | | } |
| | | } |
| | | if (!image) { |
| | | return null; |
| | | } |
| | | const icon = new AMap.Icon({ |
| | | image, |
| | | size: new AMap.Size(30, 30), |
| | | imageSize: new AMap.Size(30, 30), |
| | | }); |
| | | const marker = new AMap.Marker({ |
| | | position: item.position, |
| | | icon, |
| | | offset: new AMap.Pixel(-12, -12), |
| | | extData: { |
| | | category: item.category, |
| | | level: item.level, |
| | | }, |
| | | }); |
| | | return marker; |
| | | }, |
| | | updateMarkerVisibility() { |
| | | if (!this.markers || !this.markers.length) { |
| | | return; |
| | | } |
| | | this.markers.forEach((marker) => { |
| | | if (!marker) { |
| | | return; |
| | | } |
| | | const data = marker.getExtData ? marker.getExtData() : null; |
| | | if (!data) { |
| | | return; |
| | | } |
| | | const categoryVisible = this.categoryFilter[data.category]; |
| | | const levelVisible = this.levelFilter[data.level]; |
| | | if (categoryVisible && levelVisible) { |
| | | marker.show(); |
| | | } else { |
| | | marker.hide(); |
| | | } |
| | | }); |
| | | }, |
| | | toggleCategory(type) { |
| | | if (!this.categoryFilter.hasOwnProperty(type)) { |
| | | return; |
| | | } |
| | | this.categoryFilter[type] = !this.categoryFilter[type]; |
| | | this.updateMarkerVisibility(); |
| | | }, |
| | | toggleLevel(level) { |
| | | if (!this.levelFilter.hasOwnProperty(level)) { |
| | | return; |
| | | } |
| | | this.levelFilter[level] = !this.levelFilter[level]; |
| | | this.updateMarkerVisibility(); |
| | | }, |
| | | }, |
| | | }; |
| | | </script> |