Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit af3836d

Browse files
committed
feat(2903): 三维cesium中增加WebTileLayer图层组件
详细描述: 三维cesium中增加WebTileLayer图层组件
1 parent 14cc83c commit af3836d

File tree

5 files changed

+90
-12
lines changed

5 files changed

+90
-12
lines changed

cesium/src/component.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export { default as Mapgis3dArcgisMapLayer } from "./components/Layer/ArcGISServ
3434
export { default as Mapgis3dGraphicSingleLayer } from "./components/Layer/Graphic/GraphicSingleLayer.vue";
3535
export { default as Mapgis3dGraphicLayer } from "./components/Layer/Graphic/GraphicLayer.vue";
3636
export { default as Mapgis3dGraphicLayerService } from "./components/Layer/Graphic/GraphicLayerService.vue";
37+
export { default as Mapgis3dWebTileLayer } from "./components/Layer/WebTile/WebTileLayer";
3738

3839
// 要素图层
3940
export { default as Mapgis3dGeojsonLayer } from "./components/Layer/GeoJSON/GeoJsonLayer";

cesium/src/components/Layer/ServiceLayer.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default {
2727
},
2828
layerStyle: {
2929
type: Object,
30-
default: function() {
30+
default: function () {
3131
return {
3232
visible: true,
3333
opacity: 1
@@ -91,7 +91,7 @@ export default {
9191
},
9292
watch: {
9393
layerStyle: {
94-
handler: function() {
94+
handler: function () {
9595
let { vueKey, vueIndex } = this;
9696
let layer = window.vueCesium[this.managerName].findSource(
9797
vueKey,
@@ -114,7 +114,7 @@ export default {
114114
deep: true
115115
},
116116
options: {
117-
handler: function() {
117+
handler: function () {
118118
let vm = this;
119119
let isEqual = this.$_isEqual(vm.options, vm.optionsBack);
120120
if (!isEqual) {
@@ -126,7 +126,7 @@ export default {
126126
deep: true
127127
},
128128
id: {
129-
handler: function() {
129+
handler: function () {
130130
const { vueIndex, vueKey } = this;
131131
let layer = window.vueCesium[this.managerName].findSource(
132132
vueKey,
@@ -180,7 +180,7 @@ export default {
180180

181181
//取得除options、layerStyle和id之外的必要参数
182182
const { $props, vueIndex, vueKey } = this;
183-
Object.keys($props).forEach(function(key) {
183+
Object.keys($props).forEach(function (key) {
184184
if (key !== "options" && key !== "layerStyle" && key !== "id") {
185185
opt[key] = $props[key];
186186
}
@@ -371,7 +371,7 @@ export default {
371371
vm = this;
372372

373373
//遍历window.vueCesium下所有的Manager
374-
Object.keys(window.vueCesium).forEach(function(key) {
374+
Object.keys(window.vueCesium).forEach(function (key) {
375375
if (key.indexOf("Manager") > -1 && key !== "GlobesManager") {
376376
//取出含有与webScene组件相同vueKey的Manager对象
377377
if (window.vueCesium[key].hasOwnProperty("vueKey")) {
@@ -395,7 +395,7 @@ export default {
395395
});
396396

397397
//对数组进行排序
398-
Layers.sort(function(a, b) {
398+
Layers.sort(function (a, b) {
399399
if (a.options && b.options) {
400400
return a.options.zIndex - b.options.zIndex;
401401
}
@@ -637,7 +637,7 @@ export default {
637637
$_checkProps(checkObj, checkType) {
638638
let vm = this;
639639
if (checkObj && checkType) {
640-
Object.keys(checkObj).forEach(function(key) {
640+
Object.keys(checkObj).forEach(function (key) {
641641
let result;
642642
if (checkType.hasOwnProperty(key) && typeof key === "string") {
643643
result = vm.$_checkValue(checkObj, key, checkType[key]);
@@ -702,6 +702,14 @@ export default {
702702
tilingScheme = new Cesium.GeographicTilingScheme();
703703
} else if (tileMatrixSetName === "EPSG:3857") {
704704
tilingScheme = new Cesium.WebMercatorTilingScheme();
705+
} else if (
706+
["bd09", "bd09ll", "bd09mc", "gcj02", "gcj02ll", "gcj02mc"].indexOf(
707+
tileMatrixSetName
708+
) > -1
709+
) {
710+
tilingScheme = new Cesium.CustomTilingScheme({
711+
wkid: tileMatrixSetName
712+
});
705713
} else {
706714
tilingScheme = new Cesium.GeographicTilingScheme();
707715
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<template>
2+
<span />
3+
</template>
4+
<script>
5+
import ServiceLayer from "../ServiceLayer";
6+
7+
export default {
8+
name: "mapgis-3d-web-tile-layer",
9+
props: {
10+
baseUrl: {
11+
type: String,
12+
default: ""
13+
},
14+
spatialReference: {
15+
type: Object,
16+
default: () => {}
17+
},
18+
srs: {
19+
type: String,
20+
default: "EPSG:4326"
21+
}
22+
},
23+
data() {
24+
return {
25+
//监测props
26+
checkType: {
27+
visible: "boolean",
28+
opacity: "number",
29+
zIndex: "number",
30+
vueKey: "string",
31+
vueIndex: "string | Number"
32+
},
33+
managerName: "WebTileManager",
34+
// providerName: "BaiduImageryProvider", //cesium调用的类名
35+
providerName: "UrlTemplateImageryProvider"
36+
};
37+
},
38+
inject: ["Cesium", "vueCesium"],
39+
mixins: [ServiceLayer],
40+
created() {},
41+
mounted() {
42+
this.mount();
43+
},
44+
destroyed() {
45+
this.unmount();
46+
},
47+
methods: {
48+
mount() {
49+
let options = {};
50+
if (this.$props.spatialReference) {
51+
// 构造CustomTilingScheme
52+
options.tilingScheme = this.$_setTilingScheme(
53+
this.$props.spatialReference.wkid
54+
);
55+
}
56+
this.$_mount(options);
57+
},
58+
unmount() {
59+
this.$_unmount();
60+
}
61+
}
62+
};
63+
</script>
64+
65+
<style scoped></style>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import WebTileLayer from "./WebTileLayer";
2+
export { WebTileLayer };

cesium/src/components/WebGlobe/manager.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export function initVueCesium() {
7474
window.vueCesium.M3DIgsManager || new EventHandlerManager();
7575
window.vueCesium.ArcgisManager =
7676
window.vueCesium.ArcgisManager || new EventHandlerManager();
77+
window.vueCesium.WebTileManager =
78+
window.vueCesium.WebTileManager || new EventHandlerManager();
7779
window.vueCesium.IgsDocLayerManager =
7880
window.vueCesium.IgsDocLayerManager || new IgsDocLayerManager();
7981
window.vueCesium.IgsTilecLayerManager =
@@ -147,7 +149,7 @@ export function initVueCesium() {
147149
window.vueCesium.CompareManager || new CompareManager();
148150

149151
//在window.vueCesium下添加取得WebGlobe对象的方法
150-
window.vueCesium.getViewer = function(vueKey) {
152+
window.vueCesium.getViewer = function (vueKey) {
151153
if (!vueKey) {
152154
vueKey = "default";
153155
}
@@ -162,13 +164,13 @@ export function initVueCesium() {
162164
* @param callback 回调函数
163165
* @param vueKey vueKey,唯一标识webscene组件
164166
* */
165-
window.vueCesium.getViewerByInterval = function(callback, vueKey) {
167+
window.vueCesium.getViewerByInterval = function (callback, vueKey) {
166168
if (!vueKey) {
167169
vueKey = "default";
168170
}
169171
let ViewerManager = window.vueCesium.ViewerManager,
170172
viewer;
171-
let interval = setInterval(function() {
173+
let interval = setInterval(function () {
172174
if (
173175
ViewerManager.hasOwnProperty(vueKey) &&
174176
ViewerManager[vueKey].length > 0
@@ -298,7 +300,7 @@ export class BaseManager {
298300

299301
flatAllSource() {
300302
let flat = [];
301-
Object.keys(this).forEach(k => {
303+
Object.keys(this).forEach((k) => {
302304
if (k !== "vueKey") {
303305
flat = flat.concat(this[k]);
304306
}

0 commit comments

Comments
 (0)