Skip to content

Instantly share code, notes, and snippets.

@samthecodingman
Created May 12, 2021 10:55
Show Gist options
  • Save samthecodingman/65fecb16a855b6ee3912d1e3ea30c7ae to your computer and use it in GitHub Desktop.
Save samthecodingman/65fecb16a855b6ee3912d1e3ea30c7ae to your computer and use it in GitHub Desktop.
Typescript declaration file for @znemz/cesium-navigation
// Requires these modules to be installed:
// - @turf/helpers (dev dependency, compiled and exported by this module)
// - cesium (dependency)
declare module "@znemz/cesium-navigation" {
import { Cartographic, Rectangle, Viewer } from "cesium";
import { Units } from "@turf/helpers";
export {
Units,
earthRadius,
factors,
unitsFactors,
areaFactors,
feature,
geometry,
point,
points,
polygon,
polygons,
lineString,
lineStrings,
featureCollection,
multiLineString,
multiPoint,
multiPolygon,
geometryCollection,
round,
radiansToLength,
lengthToRadians,
lengthToDegrees,
bearingToAzimuth,
radiansToDegrees,
degreesToRadians,
convertLength,
convertArea,
isNumber,
isObject,
} from "@turf/helpers";
export interface CesiumNavigationMixinOptions {
/**
* Sets the default view when resetting the map view using the reset
* navigation control.
*/
defaultResetView: Cartographic | Rectangle;
/**
* Determines whether the distance legend is enabled.
*
* **Default:** `true`
*/
enableDistanceLegend?: boolean;
/**
* Determines whether the zoom controls are enabled.
*
* **Default:** `true`
*/
enableZoomControls?: boolean;
/**
* Determines whether the compass is enabled.
*
* **Default:** `true`
*/
enableCompass?: boolean;
/**
* The type of units to display.
*
* [The default
* implementation](https://github.com/nmccready/cesium-navigation/blob/db9997fee1da5e709c2b3e13fb7a64e051f66610/Source/Core/Utils.js#L69-L82)
* supports "meters", "millimeters", "centimeters", "kilometers", "acres",
* "miles", "nauticalmiles", "inches", "yards", "feet", "radians", and
* "degrees".
*
* **Default:** `"kilometers"`
*/
units?: Units;
/**
* Custom label formatter to override the default implementation.
*
* @see [/nmccready/cesium-navigation/Source/Core/Utils.js](https://github.com/nmccready/cesium-navigation/blob/db9997fee1da5e709c2b3e13fb7a64e051f66610/Source/Core/Utils.js#L84-L101)
*/
distanceLabelFormatter?: (
convertedDistance: number,
units: Units
) => string;
}
/**
* A mixin which adds the Compass/Navigation widget to the
* [`Viewer`](https://cesium.com/docs/cesiumjs-ref-doc/Viewer.html) widget.
* Rather than being called directly, this function is normally passed as a
* parameter to
* [`Viewer#extend`](https://cesium.com/docs/cesiumjs-ref-doc/Viewer.html?classFilter=Viewer#extend),
* as shown in the example below.
* @exports viewerCesiumNavigationMixin
*
* @param {Viewer} viewer The viewer instance.
* @param {CesiumNavigationOptions} options The options.
*
* @throws
* [`DeveloperError`](https://cesium.com/docs/cesiumjs-ref-doc/DeveloperError.html?classFilter=Developer)
* - viewer is required
*
* @example
* const viewer = new Cesium.Viewer('cesiumContainer');
* viewer.extend(viewerCesiumNavigationMixin, options);
*/
function viewerCesiumNavigationMixin(
viewer: Viewer,
options: CesiumNavigationMixinOptions
): void;
export default viewerCesiumNavigationMixin;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment