@nsc-earth-2/sync-viewer
v1.0.3
Published
`@nsc-earth-2/sync-viewer` is an npm package for synchronizing two Cesium Viewer instances. [中文 Readme](./README_CN.md)
Downloads
89
Readme
@nsc-earth-2/sync-viewer
@nsc-earth-2/sync-viewer
is an npm package for synchronizing two Cesium Viewer instances.
中文 Readme
Installation
npm install @nsc-earth-2/sync-viewer
Usage
import { Viewer } from "cesium";
import SyncViewer from "@nsc-earth-2/sync-viewer";
const leftViewer = new Viewer("left-container");
const rightViewer = new Viewer("right-container");
const syncViewer = new SyncViewer(leftViewer, rightViewer);
// Destroy
syncViewer.destroy();
API
SyncViewProps
| Property Name | Type | Description |
| ----------------- | -------- | ------------------------------------------------------------ |
| percentageChanged | number
| The percentage of distance changed when the camera zooms in. |
SyncViewer
Constructor
constructor(leftViewer: Viewer, rightViewer: Viewer, options?: SyncViewProps)
leftViewer
: A Cesium Viewer instance on the left.rightViewer
: A Cesium Viewer instance on the right.options
(optional): An object containing options:percentageChanged
: The percentage of distance changed when the camera zooms in, default to0.01
.
Methods
start()
Start synchronizing the views of the left and right viewers.
start(): void
destroy()
Destroy the instance and unsynchronize the views of the left and right viewers.
destroy(): void
Properties
synchronous
Get or set whether to synchronize the views.
synchronous: boolean;
isDestory
Get whether the instance has been destroyed.
get isDestory(): boolean
Events
leftChangeEvent()
Triggered when the view of the left viewer changes, used to synchronize the view of the right viewer.
rightChangeEvent()
Triggered when the view of the right viewer changes, used to synchronize the view of the left viewer.