| | |
| | | <template> |
| | | <div id="gis-view" ref="mapRef"></div> |
| | | <!-- 忢åºå¾å½±å --> |
| | | <div @click="handleShow" class="diqiu"> |
| | | <img src="@/assets/img/screen/dq.png" alt="" /> |
| | | </div> |
| | | <div v-show="picShow" class="earthBox"> |
| | | <div |
| | | v-for="(item, index) in views" |
| | | :key="index" |
| | | :class="['item-container', { active: currentIndex === index }]" |
| | | @click="switchView(index)" |
| | | > |
| | | <div class="icon-wrapper"> |
| | | <img :src="getImageUrl(item.icon)" :alt="item.label" /> |
| | | <span class="label">{{ item.label }}</span> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script setup> |
| | |
| | | import { useRoute } from "vue-router"; |
| | | import { EventBus } from "@/eventBus"; // å¼å
¥äºä»¶æ»çº¿ |
| | | |
| | | const views = [ |
| | | { label: "å°å¾", value: "map", icon: "å°å¾.png" }, |
| | | { label: "å½±å", value: "image", icon: "å½±å.png" }, |
| | | { label: "å°å½¢", value: "terrain", icon: "å°å½¢.png" }, |
| | | ]; |
| | | |
| | | const getImageUrl = (iconName) => { |
| | | return `/images/earth/${iconName}`; |
| | | }; |
| | | |
| | | const picShow = ref(false); |
| | | |
| | | const handleShow = () => { |
| | | picShow.value = !picShow.value; |
| | | }; |
| | | |
| | | const currentIndex = ref(-1); |
| | | |
| | | let currentLayer = null; |
| | | |
| | | const switchView = async (index) => { |
| | | currentIndex.value = index; |
| | | |
| | | // å¦æå·²ç»æå¾å±åå¨ï¼å
ä»å°å¾ä¸ç§»é¤ |
| | | if (currentLayer) { |
| | | currentLayer.removeFromMap(); |
| | | currentLayer = null; // æ¸
空å¼ç¨ |
| | | } |
| | | |
| | | if (views[index].value === "map") { |
| | | // ç¾åº¦å°å¾ |
| | | currentLayer = await earthCtrl.factory.createImageryLayer({ |
| | | sourceType: "baidu", |
| | | url: "https://ss1.bdstatic.com/8bo_dTSlR1gBo1vgoIiO_jowehsv/tile/?qt=vtile&x={x}&y={y}&z={z}&styles=pl&udt=20180810&scaler=1&showtext=1", |
| | | }); |
| | | } else if (views[index].value === "image") { |
| | | currentLayer = await earthCtrl.factory.createImageryLayer({ |
| | | sourceType: "mapworld", |
| | | url: "https://t0.tianditu.gov.cn/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=3ec79cf7a9dcc6bb18411a5414b148cb", |
| | | layers: "tdtBasicLayer", |
| | | style: "default", |
| | | format: "image/jpeg", |
| | | maximumLevel: 18, |
| | | layer: "", |
| | | tileMatrixSetID: "", |
| | | }); |
| | | //æ æ³¨å± |
| | | currentLayer = await earthCtrl.factory.createImageryLayer({ |
| | | sourceType: "mapworld", |
| | | subdomains: ["t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7"], |
| | | url: "https://{s}.tianditu.gov.cn/cia_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=cia&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&tk=c53eb074c3fcba5ac86103d4d711bbe8", |
| | | }); |
| | | } else if (views[index].value === "terrain") { |
| | | // å°å½¢å¾å± |
| | | currentLayer = await earthCtrl.factory.createTerrainLayer({ |
| | | sourceType: "arcgis", |
| | | url: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer", |
| | | }); |
| | | } |
| | | }; |
| | | const route = useRoute(); |
| | | let handler = null; |
| | | function initMap() { |
| | |
| | | |
| | | //æ¾ç¤ºfps |
| | | earthCtrl.showFPS = true; |
| | | |
| | | // ç³»ç»ç®åé»è®¤ä½¿ç¨ç |
| | | earthCtrl.factory.createImageryLayer({ |
| | | sourceType: "mapworld", |
| | | url: "http://t0.tianditu.com/img_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=img&tileMatrixSet=w&TileMatrix={TileMatrix}&TileRow={TileRow}&TileCol={TileCol}&style=default&format=tiles&tk=7eb11c0c503429878691ac917238f87f", |
| | |
| | | height: 100vh; |
| | | position: absolute; |
| | | } |
| | | |
| | | // // ä¿®æ¹æåéä½ç½® |
| | | /deep/ .compass { |
| | | right: 128px !important; |
| | | top: 112px; |
| | | } |
| | | |
| | | .diqiu { |
| | | position: absolute; |
| | | bottom: 8%; |
| | | right: 4%; |
| | | z-index: 9999; |
| | | } |
| | | |
| | | .earthBox { |
| | | z-index: 9999; |
| | | width: 12%; |
| | | height: 7%; |
| | | background-color: rgba(0, 9, 9, 0.3); |
| | | position: absolute; |
| | | right: 8%; |
| | | bottom: 6%; |
| | | display: flex; |
| | | justify-content: space-evenly; |
| | | padding: 10px 6px; |
| | | } |
| | | |
| | | .icon-wrapper { |
| | | position: relative; |
| | | margin: 0; |
| | | padding: 0; |
| | | box-sizing: border-box; |
| | | border: 1px solid transparent; /* é»è®¤éæè¾¹æ¡å ä½ */ |
| | | |
| | | img { |
| | | height: 100%; |
| | | width: auto; /* ç¡®ä¿å¾çææ¯ä¾ç¼©æ¾ */ |
| | | margin: 0; |
| | | padding: 0; |
| | | display: block; /* ç§»é¤å¾ç䏿¹å¯è½åå¨ç空ç½é´é */ |
| | | } |
| | | |
| | | .label { |
| | | position: absolute; |
| | | bottom: 0; |
| | | right: 0; |
| | | left: 0; |
| | | background-color: rgba(0, 0, 0, 0.5); |
| | | text-align: center; |
| | | color: white; |
| | | } |
| | | } |
| | | |
| | | .item-container { |
| | | position: relative; |
| | | display: inline-block; |
| | | cursor: pointer; |
| | | } |
| | | |
| | | .item-container.active .icon-wrapper { |
| | | border: 1px solid #218967; /* èè²è¾¹æ¡ */ |
| | | } |
| | | |
| | | .item-container.active .label { |
| | | background-color: rgba(33, 137, 103, 0.8); |
| | | } |
| | | </style> |