Rasterex APINPM Package/docs/guides/annotation-appearance

Modern vs Legacy Annotations

Compare Modern and Legacy on the same drawing, then enable Modern and work with Count groups in your npm integration.

Compare the Same Drawing

Legacy is the default. Modern changes how supported annotations look while you edit. You can switch modes without changing the saved annotations, their IDs, or their measurement values.

Open the workshop sample and select Side by side, then choose Count markers. Both viewers show the same six markers. Zoom in to see how their size changes in Legacy and stays fixed in Modern.

What Changes in the Editor

The screenshots show the same workshop plan at the same zoom with the Count group selected.

ExampleLegacyModern
CountNative symbols scale with the drawing. Rings show selection.Numbered disks stay the same size on screen. A badge shows the group total.
AreaNative measurement label and handles.Measurement badge and modern vertex handles.
RectangleNative editing handles.Circular corner handles and a connected rotation control for an editable rectangle.
Legacy mode with six native Count markers and the native Area label.
Legacy · Native symbols and selection rings
Modern mode with six numbered Count disks, a group total, and the Area badge.
Modern · Numbered markers and group total

Add a Marker to the Sample Group

Return to Single view to edit the sample group and check its marker total.

  • 1Choose Count markers. The sample starts with six markers.
  • 2Choose Add markers, click once on a clear spot in the drawing, then choose Done. The sample total updates to seven markers.
  • 3Switch between Legacy and Modern. The added marker stays in the same place and the group still has seven markers.

Create a Separate Count Group

Use the Count tool when you want a new group with its own total.

  • 1Choose Count in the annotation toolbar.
  • 2Click the drawing once for each marker you want to place.
  • 3Choose Finish to complete the new group. Choose Reset sample to discard demo edits and start again with the original six markers.

Enable Modern in Your Application

Mount the viewer and await viewer.ready(). Follow the Modern Annotations component to check for measurementAppearance and call viewer.styles.setMeasurementAppearance({ mode: "modern" }). Wait for the drawing to open before enabling Count controls.

Track the last confirmed mode in the parent. Disable the appearance control while the request is pending and show a retry action if Canvas rejects the switch.

Create and Extend Count Groups

Use the same Count Point Mode API in either appearance. Check for countWorkflow before enabling configuration and Finish. Check for countItemInfo before using the marker list.

  • 1Create a group. Configure the draft and activate Count. Let the operator place markers before calling count.finish(). Refresh the annotation list after Finish confirms.
  • 2Extend a group. Confirm the target is an editable native Count and use its GUID. Enable point mode, wait for Canvas to confirm it, then let the operator click the drawing.
  • 3Verify and save. Stop point mode before switching appearance, changing the target, or leaving Count. Compare marker IDs and totals before and after insertion. If a request times out, refresh the group before retrying. Use your existing save workflow to persist edits.
  • 4Clean up. Unsubscribe any Count listeners and destroy the viewer if the route owns it.

Start and finish a new group

Call Finish after the operator places the markers.

typescript
const count = viewer.annotations.count;

async function startCountGroup() {
  await count.configure({
    name: "Fixtures",
    visibility: "always",
    content: "nameValue"
  });
  await viewer.tools.set({ group: "measurement", action: "COUNT", enabled: true });
}

async function finishCountGroup() {
  await count.finish();
  const { items } = await viewer.annotations.getData({ filter: "all" });
  return items;
}

Add markers to an editable group

Use the selected Count group GUID as countGuid. Keep Start and Done in separate button handlers.

typescript
const count = viewer.annotations.count;

async function startAddingMarkers(countGuid: string) {
  const { items } = await count.getItems(countGuid);
  await count.setPointMode({ enabled: true, guid: countGuid });
  return items;
}

async function finishAddingMarkers(countGuid: string) {
  await count.setPointMode({ enabled: false });
  viewer.tools.clear();
  const { items } = await count.getItems(countGuid);
  return items;
}

Verify the Switch

  • Keep controls unavailable until Canvas and the sample drawing are ready. Indicate which appearance is active with an accessible label and pressed state.
  • Allow one mode change at a time. Keep the last confirmed appearance visible while the request is pending and show an actionable error if the request fails.
  • Finish a new Count group or stop marker insertion before switching. Verify that marker positions and totals survive the switch, and that a new viewer starts in Legacy.
  • Verify keyboard focus, screen reader status announcements, and cleanup of listeners or outstanding requests when the user leaves the route.