Snapping settings for the measurement tools. Changes apply immediately to every
tool sharing this instance.
| Name | Type | Description |
|---|---|---|
options |
MeasurementSnapping.ConstructorOptions | optional Initialization options. |
Example:
const bridge = await Cesium.IonSnapService.fromAssetId(bridgeAssetId);
const building = await Cesium.IonSnapService.fromAssetId(buildingAssetId);
viewer.extend(viewerMeasureMixin, {
snapping: {
service: (feature) =>
feature.primitive === bridgeTileset ? bridge : building,
},
});
viewer.measure.viewModel.snapping.client = false;
Members
Snap picks to nearby edges via
Scene#snap.
-
Default Value:
true
readonly disableModifier : KeyboardEventModifier
packages/ion-sdk-measurements/Source/Measure/MeasurementSnapping.js 109
Modifier key that suppresses snapping while held.
readonly errorEvent : Event
packages/ion-sdk-measurements/Source/Measure/MeasurementSnapping.js 121
Raised with the error when a snapping service request fails; the point keeps
its client position. If there are no listeners, the error is logged to the console.
getElementId : MeasurementSnapping.ElementIdCallback
packages/ion-sdk-measurements/Source/Measure/MeasurementSnapping.js 96
Returns the
elementId passed to SnapService#snap for a picked feature.
Example:
// For a tileset that isn't from the BIM/CAD tiler, read its own numeric id
// property; otherwise use the default (`element`).
const snapping = viewer.measure.viewModel.snapping;
const getBimCadElementId = snapping.getElementId;
snapping.getElementId = (feature) =>
feature.primitive === otherTileset
? `${feature.getProperty("id")}`
: getBimCadElementId(feature);
service : SnapService|MeasurementSnapping.ServiceCallback|undefined
packages/ion-sdk-measurements/Source/Measure/MeasurementSnapping.js 80
The
SnapService used to refine placed points, or a function returning one for a picked feature.
Type Definitions
IonSdkMeasurements.MeasurementSnapping.ConstructorOptions
packages/ion-sdk-measurements/Source/Measure/MeasurementSnapping.js 19
Initialization options for the
MeasurementSnapping constructor.
Properties:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
client |
Boolean |
<optional> |
true | Snap picks to nearby edges via Scene#snap. On by default; set to false to opt out. Surfaces use the exact cursor pick; a surface snap is only used when nothing else is under the cursor. |
service |
SnapService | MeasurementSnapping.ServiceCallback |
<optional> |
Opt-in server-side refinement: a SnapService, e.g. an IonSnapService, or a function returning the service for a picked feature. Each point is refined asynchronously after it's placed (on click), starting from its client-snapped position; labels show "≈" until the result arrives. Off unless provided. |
|
getElementId |
MeasurementSnapping.ElementIdCallback |
<optional> |
Returns the elementId passed to SnapService#snap for a picked feature. Defaults to the feature's numeric element property (set by BIM/CAD tilesets), formatted as a decimal string for IonSnapService. |
|
disableModifier |
KeyboardEventModifier |
<optional> |
KeyboardEventModifier.ALT | Modifier key that suppresses snapping while held. Only read by MeasurementMouseHandler. Avoid SHIFT, which some tools already use (e.g. direction clamping in HorizontalMeasurement). |
IonSdkMeasurements.MeasurementSnapping.ElementIdCallback(feature) → String|undefined
packages/ion-sdk-measurements/Source/Measure/MeasurementSnapping.js 37
Returns the
SnapService element id for a picked feature. Called for each
placed point that a service refines.
| Name | Type | Description |
|---|---|---|
feature |
Object |
The picked feature, e.g. a Cesium3DTileFeature. |
Returns:
The element id, or
undefined to skip refinement.
IonSdkMeasurements.MeasurementSnapping.ServiceCallback(feature) → SnapService|undefined
packages/ion-sdk-measurements/Source/Measure/MeasurementSnapping.js 30
Returns the snapping service for a picked feature.
| Name | Type | Description |
|---|---|---|
feature |
Object |
The picked feature, e.g. a Cesium3DTileFeature. |
Returns:
The service, or
undefined to skip refinement.
