# @nsc-earth-v2/compass

> A compass widget for [Cesium](https://cesium.com/) based on [@nsc-earth-v2/common](https://www.npmjs.com/package/@nsc-earth-v2/common) library. [中文 Readme](./README_CN.md)

Latest version **1.1.1** (published 2024-02-27) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @nsc-earth-v2/compass
pnpm add @nsc-earth-v2/compass
yarn add @nsc-earth-v2/compass
bun add @nsc-earth-v2/compass
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2024-02-27 |
| First published | 2024-02-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | hongfaqiu |
| Maintainers | wodehaochide |
| Keywords | cesium, widget, compass |

## Links

- npm: https://www.npmjs.com/package/@nsc-earth-v2/compass
- Repository: https://github.com/hongfaqiu/nsc-earth-v2
- Homepage: https://github.com/hongfaqiu/nsc-earth-v2#readme
- Issues: https://github.com/hongfaqiu/nsc-earth-v2/issues
- npm.io page: https://npm.io/package/@nsc-earth-v2/compass

## Dependencies (1)

- [@nsc-earth-v2/common](https://npm.io/package/@nsc-earth-v2/common.md) ^1.0.1

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2024-02-27

## README

# @nsc-earth-v2/compass

A compass widget for [Cesium](https://cesium.com/) based on [@nsc-earth-v2/common](https://www.npmjs.com/package/@nsc-earth-v2/common) library.
[中文 Readme](./README_CN.md)

## Installation

```bash
npm install @nsc-earth-v2/compass
```

## Usage

The `Compass` widget can be used in a Cesium app to display a compass. To use the widget, first import it into your project:

```javascript
import Compass from "@nsc-earth-v2/compass";
```

Next, create a new instance of the widget and pass it your Cesium Viewer instance:

```javascript
const viewer = new Cesium.Viewer("cesiumContainer");
const compass = new Compass(viewer);
```

You can also customize the widget by passing an options object when creating a new instance:

```javascript
const compass = new Compass(viewer, {
  container: document.getElementById("compass-container"),
  tips: {
    inner: "North",
    outer: "Rotate",
  },
});
```

## API

### `constructor(viewer: Cesium.Viewer, options?: CompassOptions)`

Creates a new instance of the `Compass` widget attached to the specified Cesium Viewer.

#### Parameters

- `viewer`: The Cesium Viewer instance to attach the widget to.
- `options` (optional): An object containing optional parameters for the widget.

#### `enabled`

A boolean property that controls whether the widget is enabled or not.

#### `ready`

A boolean property indicating whether the widget is ready or not.

### `hide()`

A method for hiding the widget.

### `show()`

A method for showing the widget.

### `destroy(): void`

Mounts the content of the widget.

## Options

The following options can be passed when creating a new instance of the `Compass` widget:

- `container` (optional): The DOM element to mount the widget to. Defaults to `viewer.container`.
- `tips` (optional): An object containing strings for the inner and outer tips of the compass. Defaults to `{ inner: '', outer: 'Drag outer ring: rotate view.\nDrag inner gyroscope: free orbit.\nDouble-click: reset view.\nTIP: You can also free orbit by holding the CTRL key and dragging the map.' }`.

---
_Source: https://npm.io/package/@nsc-earth-v2/compass · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
