区块链技术博客
www.b2bchain.cn

Cesium 分屏对比(多窗口同步)求职学习资料

本文介绍了Cesium 分屏对比(多窗口同步)求职学习资料,有助于帮助完成毕业设计以及求职,是一篇很好的资料。

对技术面试,学习经验等有一些体会,在此分享。

Cesium 分屏对比(多窗口同步)
项目中有时候需要同时展示不同时期的历史数据,如通过村庄影像对比来展示村庄的变迁过程。比较常用的展示方式有卷帘、分屏。卷帘效果官方有例子介绍,这里介绍一种分屏对比的实现方式,供参考。

1、分屏逻辑代码
“`javascript
import * as Cesium from ‘cesium’;

const syncHandler = {
initViewer1(e) {
this.viewer1 = new Cesium.Viewer(e, {
infoBox: false,
selectionIndicator: false,
navigation: false,
animation: false,
shouldAnimate: false,
timeline: false,
baseLayerPicker: false,
geocoder: false,
homeButton: false,
sceneModePicker: false,
navigationHelpButton: false,
imageryProvider: new Cesium.UrlTemplateImageryProvider({
url: ‘https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}’,
}),
});
},
initViewer2(e) {
this.viewer2 = new Cesium.Viewer(e, {
infoBox: false,
selectionIndicator: false,
navigation: false,
animation: false,
shouldAnimate: false,
timeline: false,
baseLayerPicker: false,
geocoder: false,
homeButton: false,
sceneModePicker: false,
navigationHelpButton: false,
imageryProvider: new Cesium.UrlTemplateImageryProvider({
url: ‘https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}’,
}),
});
},
setView() {
const e = {
destination: {
x: -2265803.0128967767, y: 5013924.166733887, z: 3254489.2128794417,
},
orientation: {
heading: 0,
pitch: -90,
roll: 0,
},
duration: 1,
};
this.viewer1.scene.camera.flyTo(e);
this.viewer2.scene.camera.flyTo(e);
},
destroy() {
this.viewer1.entities.removeAll();
this.viewer1.imageryLayers.removeAll(true);
this.viewer1.destroy();
this.viewer2.entities.removeAll();
this.viewer2.imageryLayers.removeAll(true);
this.viewer2.destroy();
},
};

class SyncViewer {
constructor(i, t) {
this.viewer1 = i;
this.viewer2 = t;
this.focusIndex = 0;
}

sync(e) {
this.isSync = e;
e ? this.startSync() : this.cancelSync();
}

startSync() {
this.viewer1.scene.postRender.addEventListener(this.syncEventHandler, this);
const e = this;
this.viewer1.container.onmouseenter = function () {
e.focusIndex = 0;
};
e.viewer2.container.onmouseenter = function () {
e.focusIndex = 1;
};
}

cancelSync() {
this.viewer1.container.onmouseenter = undefined;

Cesium 分屏对比(多窗口同步)
项目中有时候需要同时展示不同时期的历史数据,如通过村庄影像对比来展示村庄的变迁过程。比较常用的展示方式有卷帘、分屏。卷帘效果官方有例子介绍,这里介绍一种分屏对比的实现方式,供参考。

1、分屏逻辑代码
“`javascript
import * as Cesium from ‘cesium’;

const syncHandler = {
initViewer1(e) {
this.viewer1 = new Cesium.Viewer(e, {
infoBox: false,
selectionIndicator: false,
navigation: false,
animation: false,
shouldAnimate: false,
timeline: false,
baseLayerPicker: false,
geocoder: false,
homeButton: false,
sceneModePicker: false,
navigationHelpButton: false,
imageryProvider: new Cesium.UrlTemplateImageryProvider({
url: ‘https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}’,
}),
});
},
initViewer2(e) {
this.viewer2 = new Cesium.Viewer(e, {
infoBox: false,
selectionIndicator: false,
navigation: false,
animation: false,
shouldAnimate: false,
timeline: false,
baseLayerPicker: false,
geocoder: false,
homeButton: false,
sceneModePicker: false,
navigationHelpButton: false,
imageryProvider: new Cesium.UrlTemplateImageryProvider({
url: ‘https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}’,
}),
});
},
setView() {
const e = {
destination: {
x: -2265803.0128967767, y: 5013924.166733887, z: 3254489.2128794417,
},
orientation: {
heading: 0,
pitch: -90,
roll: 0,
},
duration: 1,
};
this.viewer1.scene.camera.flyTo(e);
this.viewer2.scene.camera.flyTo(e);
},
destroy() {
this.viewer1.entities.removeAll();
this.viewer1.imageryLayers.removeAll(true);
this.viewer1.destroy();
this.viewer2.entities.removeAll();
this.viewer2.imageryLayers.removeAll(true);
this.viewer2.destroy();
},
};

class SyncViewer {
constructor(i, t) {
this.viewer1 = i;
this.viewer2 = t;
this.focusIndex = 0;
}

sync(e) {
this.isSync = e;
e ? this.startSync() : this.cancelSync();
}

startSync() {
this.viewer1.scene.postRender.addEventListener(this.syncEventHandler, this);
const e = this;
this.viewer1.container.onmouseenter = function () {
e.focusIndex = 0;
};
e.viewer2.container.onmouseenter = function () {
e.focusIndex = 1;
};
}

cancelSync() {
this.viewer1.container.onmouseenter = undefined;

Cesium 分屏对比(多窗口同步)
项目中有时候需要同时展示不同时期的历史数据,如通过村庄影像对比来展示村庄的变迁过程。比较常用的展示方式有卷帘、分屏。卷帘效果官方有例子介绍,这里介绍一种分屏对比的实现方式,供参考。

1、分屏逻辑代码
“`javascript
import * as Cesium from ‘cesium’;

const syncHandler = {
initViewer1(e) {
this.viewer1 = new Cesium.Viewer(e, {
infoBox: false,
selectionIndicator: false,
navigation: false,
animation: false,
shouldAnimate: false,
timeline: false,
baseLayerPicker: false,
geocoder: false,
homeButton: false,
sceneModePicker: false,
navigationHelpButton: false,
imageryProvider: new Cesium.UrlTemplateImageryProvider({
url: ‘https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}’,
}),
});
},
initViewer2(e) {
this.viewer2 = new Cesium.Viewer(e, {
infoBox: false,
selectionIndicator: false,
navigation: false,
animation: false,
shouldAnimate: false,
timeline: false,
baseLayerPicker: false,
geocoder: false,
homeButton: false,
sceneModePicker: false,
navigationHelpButton: false,
imageryProvider: new Cesium.UrlTemplateImageryProvider({
url: ‘https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}’,
}),
});
},
setView() {
const e = {
destination: {
x: -2265803.0128967767, y: 5013924.166733887, z: 3254489.2128794417,
},
orientation: {
heading: 0,
pitch: -90,
roll: 0,
},
duration: 1,
};
this.viewer1.scene.camera.flyTo(e);
this.viewer2.scene.camera.flyTo(e);
},
destroy() {
this.viewer1.entities.removeAll();
this.viewer1.imageryLayers.removeAll(true);
this.viewer1.destroy();
this.viewer2.entities.removeAll();
this.viewer2.imageryLayers.removeAll(true);
this.viewer2.destroy();
},
};

class SyncViewer {
constructor(i, t) {
this.viewer1 = i;
this.viewer2 = t;
this.focusIndex = 0;
}

sync(e) {
this.isSync = e;
e ? this.startSync() : this.cancelSync();
}

startSync() {
this.viewer1.scene.postRender.addEventListener(this.syncEventHandler, this);
const e = this;
this.viewer1.container.onmouseenter = function () {
e.focusIndex = 0;
};
e.viewer2.container.onmouseenter = function () {
e.focusIndex = 1;
};
}

cancelSync() {
this.viewer1.container.onmouseenter = undefined;

部分转自互联网,侵权删除联系

赞(0) 打赏
部分文章转自网络,侵权联系删除b2bchain区块链学习技术社区 » Cesium 分屏对比(多窗口同步)求职学习资料
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

b2b链

联系我们联系我们