|
|
|
@ -384,8 +384,9 @@ export default { |
|
|
|
this.viewer.cesiumWidget.creditContainer.style.display = "none" |
|
|
|
this.loadOfflineMap() |
|
|
|
this.setup2DConstraints() |
|
|
|
// 初始视野:中国中心(仅中国瓦片时无需世界瓦片,国外区域会无瓦片显示为空白) |
|
|
|
this.viewer.camera.setView({ |
|
|
|
destination: Cesium.Cartesian3.fromDegrees(116.3974, 39.9093, 5000000), |
|
|
|
destination: Cesium.Cartesian3.fromDegrees(116.3974, 39.9093, 12000000), |
|
|
|
orientation: { |
|
|
|
heading: 0, |
|
|
|
pitch: -Cesium.Math.PI_OVER_TWO, |
|
|
|
@ -563,19 +564,32 @@ export default { |
|
|
|
loadOfflineMap() { |
|
|
|
this.viewer.imageryLayers.removeAll() |
|
|
|
try { |
|
|
|
// 修改部分:将原来的 ArcGIS 卫星图替换为高德矢量行政图 |
|
|
|
const administrativeMap = new Cesium.UrlTemplateImageryProvider({ |
|
|
|
// 高德地图矢量瓦片服务(纯 2D 行政图风格) |
|
|
|
url: 'https://webrd02.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}', |
|
|
|
// 使用本地瓦片(tiles 目录,结构:z/x/y.png)替代高德在线地图 |
|
|
|
const origin = typeof window !== 'undefined' ? window.location.origin : '' |
|
|
|
const tilesUrl = origin + '/tiles/{z}/{x}/{reverseY}.png' |
|
|
|
const tilingScheme = new Cesium.WebMercatorTilingScheme() |
|
|
|
const chinaRect = Cesium.Rectangle.fromDegrees(73.5, 18.0, 135.0, 53.5) |
|
|
|
// 底层:全球 0–8 级(境外和中国在 0–8 级都显示) |
|
|
|
const worldTiles = new Cesium.UrlTemplateImageryProvider({ |
|
|
|
url: tilesUrl, |
|
|
|
minimumLevel: 0, |
|
|
|
maximumLevel: 18, |
|
|
|
// 高德不需要专门的 TilingScheme,默认即可,或者使用 WebMercator |
|
|
|
tilingScheme: new Cesium.WebMercatorTilingScheme() |
|
|
|
maximumLevel: 8, |
|
|
|
tilingScheme, |
|
|
|
credit: '' |
|
|
|
}) |
|
|
|
this.viewer.imageryLayers.addImageryProvider(administrativeMap) |
|
|
|
// 如果需要叠加路网或注记,可以在这里再 add 一个图层 |
|
|
|
this.viewer.imageryLayers.addImageryProvider(worldTiles) |
|
|
|
// 顶层:仅中国范围 0–14 级(中国内可缩放到 14 级,境外不请求) |
|
|
|
const chinaTiles = new Cesium.UrlTemplateImageryProvider({ |
|
|
|
url: tilesUrl, |
|
|
|
minimumLevel: 0, |
|
|
|
maximumLevel: 14, |
|
|
|
rectangle: chinaRect, |
|
|
|
tilingScheme, |
|
|
|
credit: '' |
|
|
|
}) |
|
|
|
this.viewer.imageryLayers.addImageryProvider(chinaTiles) |
|
|
|
} catch (error) { |
|
|
|
console.error('加载地图失败:', error) |
|
|
|
console.error('加载本地瓦片失败:', error) |
|
|
|
this.showGridLayer() |
|
|
|
} |
|
|
|
}, |
|
|
|
|