2024-10-16 15:22:42 +08:00
|
|
|
import { getParamsList } from '../api/home'
|
|
|
|
|
|
2024-09-29 11:33:55 +08:00
|
|
|
export function modifyCesiumMouseWheel(viewer) {
|
|
|
|
|
// 地图缩放改为按下 Ctrl + 鼠标滚轮
|
|
|
|
|
viewer.scene.screenSpaceCameraController.zoomEventTypes = [{ eventType: Cesium.CameraEventType.WHEEL, modifier: Cesium.KeyboardEventModifier.CTRL }];
|
|
|
|
|
|
|
|
|
|
// 改写 Cesium 原生鼠标滚轮事件
|
|
|
|
|
const handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
|
|
|
|
|
handler.setInputAction((event) => {
|
|
|
|
|
if (event < 0) {
|
|
|
|
|
window.scrollBy({ left: 0, top: 15, behavior: 'auto' });
|
|
|
|
|
} else {
|
|
|
|
|
window.scrollBy({ left: 0, top: -15, behavior: 'auto' });
|
|
|
|
|
}
|
|
|
|
|
}, Cesium.ScreenSpaceEventType.WHEEL);
|
|
|
|
|
|
|
|
|
|
// 鼠标移动时显示提示信息
|
|
|
|
|
handler.setInputAction((event) => {
|
|
|
|
|
document.getElementById('mouseWheelTip').style.display = '';
|
|
|
|
|
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
|
|
|
|
|
}
|
2024-10-16 15:22:42 +08:00
|
|
|
|
|
|
|
|
let imageryViewModels = [];
|
|
|
|
|
export function setImageryViewModels(cesiumHostAddr) {
|
|
|
|
|
if (imageryViewModels.length == 0) {
|
2025-09-08 19:28:19 +08:00
|
|
|
// 世界影像地图
|
|
|
|
|
const world_imagery = new Cesium.WebMapTileServiceImageryProvider(
|
|
|
|
|
{
|
|
|
|
|
url: 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer'
|
|
|
|
|
// url: 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer'
|
|
|
|
|
// url: 'https://services.arcgisonline.com/ArcGIS/rest/services/Ocean/World_Ocean_Base/MapServer'
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-10-16 15:22:42 +08:00
|
|
|
// 彩色地形底图
|
|
|
|
|
const colorMap = new Cesium.WebMapTileServiceImageryProvider(
|
|
|
|
|
{
|
|
|
|
|
url: cesiumHostAddr + 'geoserver/gwc/service/wmts/rest/ougp:world/{TileMatrixSet}/{TileMatrixSet}:{TileMatrix}/{TileRow}/{TileCol}?format=image/jpeg',
|
|
|
|
|
layer: 'ougp:world',
|
|
|
|
|
style: 'default',
|
|
|
|
|
format: 'image/jpeg',
|
|
|
|
|
tileMatrixSetID: 'EPSG:4326',
|
|
|
|
|
tilingScheme: new Cesium.GeographicTilingScheme()
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
// 灰度地形底图
|
|
|
|
|
const grayMap = new Cesium.WebMapTileServiceImageryProvider(
|
|
|
|
|
{
|
|
|
|
|
url: cesiumHostAddr + 'geoserver/gwc/service/wmts/rest/ougp:world_gray/{TileMatrixSet}/{TileMatrixSet}:{TileMatrix}/{TileRow}/{TileCol}?format=image/jpeg',
|
|
|
|
|
layer: 'ougp:world_gray',
|
|
|
|
|
style: 'default',
|
|
|
|
|
format: 'image/jpeg',
|
|
|
|
|
tileMatrixSetID: 'EPSG:4326',
|
|
|
|
|
tilingScheme: new Cesium.GeographicTilingScheme()
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
// 自定义底图
|
2025-09-08 19:28:19 +08:00
|
|
|
imageryViewModels.push(new Cesium.ProviderViewModel({
|
|
|
|
|
name: "世界影像地图",
|
|
|
|
|
iconUrl: "static/images/world_imagery.png",
|
|
|
|
|
tooltip: "世界影像地图",
|
|
|
|
|
creationFunction: function () {
|
|
|
|
|
return world_imagery;
|
|
|
|
|
}
|
|
|
|
|
}));
|
2024-10-16 15:22:42 +08:00
|
|
|
imageryViewModels.push(new Cesium.ProviderViewModel({
|
|
|
|
|
name: "地形地图",
|
|
|
|
|
iconUrl: "static/images/world_color.png",
|
|
|
|
|
tooltip: "彩色地形底图",
|
|
|
|
|
creationFunction: function () {
|
|
|
|
|
return colorMap;
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
imageryViewModels.push(new Cesium.ProviderViewModel({
|
|
|
|
|
name: "灰度地图",
|
|
|
|
|
iconUrl: "static/images/world_gray.png",
|
|
|
|
|
tooltip: "灰度地形底图",
|
|
|
|
|
creationFunction: function () {
|
|
|
|
|
return grayMap;
|
|
|
|
|
}
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
return imageryViewModels;
|
|
|
|
|
}
|