Cesium实现加载GIS数字地球
前言
本文主要实现使用vue3 + cesium绘制GIS数字地球,并实现点击事件
前置准备
安装cesium
此处注意,cesium不同版本之间有着差异,并不是最新版本就是最好的,对于项目来说,实用优先。
1 | npm install cesium@1.76.0 |
复制目录
在node_modules中找到cesium,拷贝到项目/public下,保留Build和Source文件夹,其他文件删掉。
找到index.html,引入资源
1 | <link rel="stylesheet" href="/cesium/Build/Cesium/Widgets/widgets.css" /> |
GisMap组件
components中新建文件夹GisMap,目录下新建两个文件,cesium.ts和index.vue
cesium.ts代码逻辑
1 | import * as Cesium from 'cesium'; |
index.vue
1 | <template> |
在页面中引用
1 | <template> |
GIS瓦片资源
高德街道:http://webrd02.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}
高德卫星图:http://webst02.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=6&x={x}&y={y}&z={z}
GeoQ彩色:https://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineCommunity/MapServer/tile/{z}/{y}/{x}
GeoQ灰色:http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetGray/MapServer/tile/{z}/{y}/{x}
OpenStreetMap Mapnick http://tile.openstreetmap.org/{z}/{x}/{y}.png
OSM Cycle Map http://tile.thunderforest.com/cycle/{z}/{x}/{y}.png
OSM Black and White http://tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png
Esri Imagery/Satellite https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}
Esri Streets https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}
Esri Topo https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}
World Light Gray Base https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}
Carto Positron https://cartodb-basemaps-a.global.ssl.fastly.net/light_all/{z}/{x}/{y}.png
cartocdn light nolabels https://basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}{r}.png
Stamen Terrain http://a.tile.stamen.com/terrain/{z}/{x}/{y}.png