@cesium-extends/sync-viewer
v1.0.1
Published
`@cesium-extends/sync-viewer` is an npm package for synchronizing two Cesium Viewer instances. [中文 Readme](./README_CN.md)
Downloads
209
Readme
@cesium-extends/sync-viewer
@cesium-extends/sync-viewer
is an npm package for synchronizing two Cesium Viewer instances.
中文 Readme
Installation
npm install @cesium-extends/sync-viewer
Usage
import { Viewer } from "cesium";
import SyncViewer from "@cesium-extends/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.