首页启用 mapbox 地图控件,优化相关交互逻辑。

This commit is contained in:
hym 2025-11-21 23:09:27 +08:00
parent 96585b087b
commit 220da59e62
1 changed files with 136 additions and 56 deletions

View File

@ -65,35 +65,19 @@
<div class="guiji_2">
<div id="cesiumContainer" ref="cesiumContainer"
onmouseleave="document.getElementById('mouseWheelTip').style.display = 'none'"
style="height: 100%;width:100%;">
onmouseenter="document.getElementById('mouseWheelTip').style.display = ''" style="height: 100%;width:100%;">
<div class="son" style="display: none;">弹框插槽</div>
<div id="mouseWheelTip" style="display: none;">地图缩放按下 Ctrl + 鼠标滚轮</div>
<el-popover
placement="left-start"
title="航次列表"
width="300"
trigger="hover"
>
<el-popover placement="left-start" title="航次列表" width="300" trigger="hover">
<div class="contour-line">
<span>等深线</span>
<el-button
size="mini"
v-for="depth in depthOptions"
:key="depth"
:type="selectedDepths.includes(depth) ? 'primary' : ''"
@click="toggleDepth(depth)"
>
<el-button size="mini" v-for="depth in depthOptions" :key="depth"
:type="selectedDepths.includes(depth) ? 'primary' : ''" @click="toggleDepth(depth)">
{{ depth }}
</el-button>
</div>
<el-table
ref="multipleTable"
:data="voyageList"
@selection-change="handleSelectionChange"
@row-click="handleRowClick"
highlight-current-row
:current-row-key="currentVoyage"
>
<el-table ref="multipleTable" :data="voyageList" @selection-change="handleSelectionChange"
@row-click="handleRowClick" highlight-current-row :current-row-key="currentVoyage">
<el-table-column type="selection" width="50" />
<el-table-column property="voyage_name" label="航次" />
</el-table>
@ -214,37 +198,38 @@
</div>
</div>
<!-- <div class="gongju">-->
<!-- <div class="gongju_top">-->
<!-- <img src="../../static/images/shuju5.png" alt="">-->
<!-- </div>-->
<!-- <div class="gongju_con">-->
<!-- <ul>-->
<!-- <li @click="turnPage('http://10.0.82.239/analysisTools/index', 'url')">-->
<!-- <img src="../../static/images/mofang.png" alt="">-->
<!-- <p>blast基因分析工具</p>-->
<!-- </li>-->
<!-- <li @click="turnPage('http://10.0.82.239/analysisTools/index', 'url')">-->
<!-- <img src="../../static/images/mofang.png" alt="">-->
<!-- <p>温盐深分析工具</p>-->
<!-- </li>-->
<!-- <li @click="turnPage('http://10.0.82.239/analysisTools/index', 'url')">-->
<!-- <img src="../../static/images/mofang.png" alt="">-->
<!-- <p>影像数据物种智能识别</p>-->
<!-- </li>-->
<!-- <li @click="turnPage('http://10.0.82.239/analysisTools/index', 'url')">-->
<!-- <img src="../../static/images/mofang.png" alt="">-->
<!-- <p>海洋物理生态耦合模式分析</p>-->
<!-- </li>-->
<!-- </ul>-->
<!-- </div>-->
<!-- </div>-->
<!-- <div class="gongju">-->
<!-- <div class="gongju_top">-->
<!-- <img src="../../static/images/shuju5.png" alt="">-->
<!-- </div>-->
<!-- <div class="gongju_con">-->
<!-- <ul>-->
<!-- <li @click="turnPage('http://10.0.82.239/analysisTools/index', 'url')">-->
<!-- <img src="../../static/images/mofang.png" alt="">-->
<!-- <p>blast基因分析工具</p>-->
<!-- </li>-->
<!-- <li @click="turnPage('http://10.0.82.239/analysisTools/index', 'url')">-->
<!-- <img src="../../static/images/mofang.png" alt="">-->
<!-- <p>温盐深分析工具</p>-->
<!-- </li>-->
<!-- <li @click="turnPage('http://10.0.82.239/analysisTools/index', 'url')">-->
<!-- <img src="../../static/images/mofang.png" alt="">-->
<!-- <p>影像数据物种智能识别</p>-->
<!-- </li>-->
<!-- <li @click="turnPage('http://10.0.82.239/analysisTools/index', 'url')">-->
<!-- <img src="../../static/images/mofang.png" alt="">-->
<!-- <p>海洋物理生态耦合模式分析</p>-->
<!-- </li>-->
<!-- </ul>-->
<!-- </div>-->
<!-- </div>-->
<Footer />
</div>
</template>
<script>
import Vue from 'vue'
import Footer from '../components/public/Footer'
import { getVoyage, statisticsNums } from '../api/home'
import { swiper, swiperSlide } from 'vue-awesome-swiper'
@ -253,6 +238,9 @@ import { sampleDatasetList, voyageRegList } from '@/api/dataTransfer'
import {
modifyCesiumMouseWheel, setImageryViewModels
} from '@/utils/common'
import { loadVectorLayer } from '@/utils/vector-layer-utils'
import { ColorGenerator } from '@/utils/color-generator';
import { handleWheel } from "@/utils/mapbox-utils";
const Cesium = window.Cesium
@ -336,7 +324,7 @@ export default {
},
mounted() {
this.imageryViewModels = setImageryViewModels(this.CesiumHostAddr)
this.initCesium()
this.initMapbox()
},
methods: {
//
@ -345,7 +333,16 @@ export default {
start: 0,
limit: 10
}).then(res => {
this.voyageList = res.page.records
this.voyageList = res.page.records;
let i = 0;
const colors = ColorGenerator.generateDivergingColors(this.voyageList.length);
this.voyageList.forEach(element => {
//
loadVectorLayer(element.voyage_name, ["line", "symbol"], [colors[i], colors[i]], "visible", "home", "dsds");
i++;
});
this.$nextTick(() => {
//
this.$refs.multipleTable.toggleAllSelection()
@ -353,6 +350,77 @@ export default {
})
},
// mapbox
initMapbox() {
window.mapboxgl.accessToken = 'pk.eyJ1IjoicWRod2kiLCJhIjoiY2xiaXppcjEyMGNhMjNwbzVrcHl4d20zOSJ9.0ETMJM3-zllFh2GRrRVUZg'
const map = new window.mapboxgl.Map({
container: 'cesiumContainer',
// style: 'mapbox://styles/mapbox/standard',
style: {
"version": 8,
"name": "default_style",
// mapbox使
"sprite": `${Vue.config.baseUrl}/oe/${Vue.config.wwwrootBaseUrl}/sprites/sprite`,
// 使
"glyphs": "mapbox://fonts/mapbox/{fontstack}/{range}.pbf",
// glyphs 404
// "glyphs": `${Vue.config.baseUrl}/oe/${Vue.config.wwwrootBaseUrl}/glyphs/{fontstack}/{range}.pbf`,
"sources": {
"影像地图": {
"type": "raster",
"tiles": ["https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"],
"tileSize": 256,
// "minzoom": 0,
// "maxzoom": baseMapMaxZoom
}
},
"layers": [
{
"id": "影像地图",
"type": "raster",
"source": "影像地图",
"layout": { visibility: "visible" },
// "minzoom": 0,
// "maxzoom": baseMapMaxZoom
}
]
},
config: {
basemap: {
theme: 'monochrome',
lightPreset: 'night'
}
},
zoom: 5,
center: [113, 15.5],
minZoom: 2,
maxZoom: 29,
trackResize: true,
scrollZoom: false, //
//
localIdeographFontFamily: "Microsoft YoHei, 'Noto Sans', 'Noto Sans CJK SC', sans-serif",
pitch: 0,
bearing: 0,
// maxBounds: [[-180, -90], [180, 90]],// Set the map's geographical boundaries.
antialias: true,
attributionControl: false,
boxZoom: true,//trueshift
preserveDrawingBuffer: false,//truecanvas使pngmap.getCanvas().toDataURL()false
projection: 'equirectangular', // 26
});
Vue.config.maps["home"] = map;
handleWheel("home");
map.on('load', () => {
// 线
// loadVectorLayer("GSHHS_f_L1", ["line"], ["#FEFEFE"], "home", 'ougp');
// 线
loadVectorLayer("contour-4500m", ["line"], ["#FEFEFE"], "none", "home", 'ougp');
loadVectorLayer("contour-6000m", ["line"], ["#FEFEFE"], "none", "home", 'ougp');
});
},
// cesium
initCesium() {
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkY2Y5NWY2Ni1mODQ1LTQ3YTUtYjc4Zi1jYzhjMGI2YzcxMWYiLCJpZCI6MTI5ODMwLCJpYXQiOjE2Nzk0Njk5NTd9.DTH54ioOH-HLqeNIetBe9hFyrPOX2Vp1AQmZzw8TIZ4'
@ -432,6 +500,14 @@ export default {
},
//
handleRowClick(row, column, event) {
// /
let visibility = Vue.config.maps["home"].getLayoutProperty(`vector-${row.voyage_name}-symbol`, "visibility");
visibility = visibility == "visible" ? "none" : "visible";
Vue.config.maps["home"].setLayoutProperty(`vector-${row.voyage_name}-symbol`, "visibility", visibility);
Vue.config.maps["home"].setLayoutProperty(`vector-${row.voyage_name}-line`, "visibility", visibility);
this.$refs.multipleTable.toggleRowSelection(row);
return;
//
if (this.currentVoyage === row.voyage_name) {
this.clearHighlight();
@ -492,7 +568,9 @@ export default {
//
voyagesToRemove.forEach(voyage => {
this.removeSingleLineImg(voyage);
// this.removeSingleLineImg(voyage);
Vue.config.maps["home"].setLayoutProperty(`vector-${voyage}-symbol`, "visibility", "none");
Vue.config.maps["home"].setLayoutProperty(`vector-${voyage}-line`, "visibility", "none");
});
//
@ -500,7 +578,9 @@ export default {
// val
const correspondingItem = val.find(item => item.voyage_name === voyage);
if (correspondingItem) {
this.addSingleLineImg(correspondingItem);
// this.addSingleLineImg(correspondingItem);
Vue.config.maps["home"].setLayoutProperty(`vector-${voyage}-symbol`, "visibility", "visible");
Vue.config.maps["home"].setLayoutProperty(`vector-${voyage}-line`, "visibility", "visible");
}
});
@ -517,7 +597,6 @@ export default {
return;
}
//
const trackLine = new Cesium.WebMapTileServiceImageryProvider({
url: `${this.CesiumHostAddr}geoserver/gwc/service/wmts/rest/dsds:${voyageName}/{TileMatrixSet}/{TileMatrixSet}:{TileMatrix}/{TileRow}/{TileCol}?format=image/png`,
layer: `dsds:${voyageName}`,
@ -552,10 +631,12 @@ export default {
const index = this.selectedDepths.indexOf(depth);
if (index > -1) {
this.selectedDepths.splice(index, 1); //
this.removeSingleContourLine(depth); // 线
// this.removeSingleContourLine(depth); // 线
Vue.config.maps["home"].setLayoutProperty(`vector-contour-${depth}m-line`, "visibility", "none");
} else {
this.selectedDepths.push(depth); //
this.addSingleContourLine(depth); // 线
// this.addSingleContourLine(depth); // 线
Vue.config.maps["home"].setLayoutProperty(`vector-contour-${depth}m-line`, "visibility", "visible");
}
},
// 线
@ -1356,8 +1437,7 @@ export default {
justify-content: center;
img {
width: auto;
height: auto;
width: auto; height: auto;
display: block;
margin-bottom: 20px;
}