Developers/Graphics JS/Components/Green measurements

Smart Component 09

Green measurements.

Green measurements turns protected mapped dimensions into a locked SVG measurement layer. Center mode uses center width plus approach-relative depth; maximum mode uses maximum width plus the same depth axis. The browser receives only final line pixels, visible yardage text and its safe display value, and safe outward label directions.

type: "green-measurements"component: caddie-green-measurementsProtected placement

Usage

Add the green measurements to a graphic.

Include the component in the initial mount call, reconcile it through view.setSmartComponents, or append it with view.addSmartComponent. Types may repeat. Give repeated instances stable id values to style, show, hide, move, reset, or remove one instance independently. The selected Smart Component type, instance ID, render receipt, and protected selection options such as yardages, grid spacing, coverage, measured origin, buffer distance, detail, limits, or targets are sent to the overlay service. Marker-image origins, images, presentation styles, supported labels, and movement remain local.

const view = await caddie.mount(container, graphicRequest, [{
  type: "green-measurements",
  origin: "green-center",
  depthLabelPosition: "top",
  widthLabelPosition: "right",
  style: {
    strokeColor: "#FFFFFF",
    strokeWidth: 4,
    strokeStyle: "solid",
    linePosition: "inside",
    endCap: "none",
    endCapSize: 10,
    showDepth: true,
    showWidth: true,
    showLabels: true,
    showDepthLabel: true,
    showWidthLabel: true,
    labelPrecision: "rounded",
    labelSize: 16,
    labelColor: "#FFFFFF",
    labelBackgroundColor: "#07110D",
    labelXPadding: 8,
    labelYPadding: 6,
    labelGap: 8,
  },
}]);

// Visibility and presentation are immediate local SVG changes.
view.setSmartComponentStyle({
  type: "green-measurements",
  style: { showWidthLabel: false, strokeColor: "#00D5FF" },
});

Defaults

Built-in presentation.

SubjectsHole · Green
MeasurementsCenter width + depth
StrokeWhite · solid · 4px
LinesInside · no end caps
LabelsBoth shown · rounded · 16px
Label sidesDepth top · width right
MovementLocked

Component options

Configure behavior and presentation.

OptionTypeDefaultDescription
type"green-measurements"RequiredRequests protected mapped depth and width instructions for a Hole or Green graphic.
idstringAutomaticOptional stable 1–64 character instance ID using letters, numbers, underscores, or hyphens. Use IDs to independently control repeated Smart Components of the same type.
origin"green-center" | "maximum-dimensions""green-center"Uses center width plus depth, or maximum width plus depth. If the selected width is unavailable, the other measured width is used and reported through resolvedOrigin.
depthLabelPosition"top" | "bottom""top"Selects the inside depth-label edge and, in outside mode, the side to which the complete width line moves.
widthLabelPosition"left" | "right""right"Selects the inside width-label edge and, in outside mode, the side to which the complete depth line moves.
style.strokeColor#RRGGBB"#FFFFFF"Local SVG color shared by both measurement lines.
style.strokeWidthnumber4Shared non-scaling line width from 1 through 16 image pixels.
style.strokeStyle"solid" | "dashed" | "dotted" | "dash-dot""solid"Shared local line pattern.
style.linePosition"inside" | "outside""inside"Keeps both measured spans over the green or translates both complete spans beyond the selected sides without changing their lengths or angles.
style.endCap"none" | "dot" | "point""none"Adds matching dots or outward-facing triangular points to both ends of each displayed line.
style.endCapSizenumber10Dot diameter or triangular point length from 4 through 32 image pixels.
style.showDepthbooleantrueShows or hides the depth line and its label locally.
style.showWidthbooleantrueShows or hides the width line and its label locally.
style.showLabelsbooleantrueShows or hides both measurement labels while preserving the depth- and width-specific settings.
style.showDepthLabelbooleantrueShows or hides only the depth yardage label locally.
style.showWidthLabelbooleantrueShows or hides only the width yardage label locally.
style.labelPrecision"rounded" | "measured""rounded"Shows whole yards by default. Measured preserves one decimal place when needed.
style.labelSizenumber16Positive whole-number shared yardage-label font size in image pixels with no upper limit.
style.labelColor#RRGGBB"#FFFFFF"Shared local yardage text color.
style.labelBackgroundColor#RRGGBB"#07110D"Shared local pill background color.
style.labelXPaddingnumber8Horizontal label padding from 0 through 32 image pixels.
style.labelYPaddingnumber6Vertical label padding from 0 through 20 image pixels.
style.labelGapnumber8Non-negative whole-number inside-label distance from its endpoint, or outside-line clearance beyond the selected green edge, with no upper limit.

Behavior

Important implementation details.

  • Depth follows the stored approach-relative axis from one measured green edge to the other. Width uses the stored center or maximum cross-section rather than an estimated image-aligned span.
  • Maximum mode uses maximum width when available; center width is its fallback. Center mode applies the inverse fallback. resolvedOrigin reports which width geometry was actually used.
  • Inside mode keeps the depth label horizontal and rotates the width label 90 degrees at their selected endpoints. Their endpoint and outward direction come from the final pixel line, while size, colors, padding, gap, and visibility remain local DOM presentation.
  • Outside mode translates the complete depth span toward the selected width side and the complete width span toward the selected depth side. Both retain their original length and angle; the depth label rotates vertically and the width label becomes horizontal at the centers of the shifted lines.
  • End caps are local SVG presentation: none by default, or matching dots or outward-facing triangular points with one shared size.
  • Changing origin or label side requests new final placement instructions. Line visibility, label visibility, stroke styling, label styling, and whole-component visibility make no overlay request.
  • The response intentionally exposes the visible yardage strings and their safe display values because they are the component content and allow local precision changes. It excludes source measurement records, source cross-sections, green polygons, coordinates, projection transforms, and the internal sidecar.
Protected course dataThe response contains only edge-to-edge line pixels, visible yardage strings, selected endpoint pixels, safe outward label directions, and the resolved origin name. Source measurement records, cross-sections, green polygons, longitude, latitude, affine transforms, and the internal render sidecar remain server-side.