Component library
One behavior engine, two placement sources.
The overlay layer contains protected Smart Components and client-authored Annotation primitives. Every component can be toggled and styled without changing the underlying image; point markers and Annotations can also support local movement and reset.
Smart Components
Course-aware placement without course-data exposure.
Tee marker
Mark the measured starting point for a hole with the built-in transparent PNG or a client-hosted PNG.
Read component guide →Flag marker
Place a flag at the measured center-green pixel while keeping the underlying graphic clean.
Read component guide →Cup marker
Place a centered golf cup image at the measured center-green pixel.
Read component guide →Approach rings
Draw measured distance rings around center green without embedding them in the downloadable graphic.
Read component guide →Approach markers
Place labeled yardage circles on the protected fairway centerline.
Read component guide →Grids
Overlay a yardage-accurate grid from green center or measured green dimensions across the image, on the green, or around a softly faded green buffer.
Read component guide →Green elevation heatmap
Visualize meaningful high and low putting-surface terrain without baking it into the graphic.
Read component guide →Green downhill arrows
Show protected putting-surface fall direction as fluid paths or a traditional arrow grid.
Read component guide →Green measurements
Draw mapped green depth and width from edge to edge with optional yardage labels outside the surface.
Read component guide →Teeboxes
Show scorecard-colored dots at the protected locations of the hole's teeboxes.
Read component guide →Teeboxes legend
Add a compact, scorecard-colored hole and yardage legend without baking it into the graphic.
Read component guide →Hole number
Place one prominent hole badge on a Hole graphic or label every hole on a complete Course graphic.
Read component guide →Shot dispersion
Connect a configurable hole start to a direct-radius target with an empirical handicap- and distance-scaled dispersion finish.
Read component guide →Hole centerline
Draw the measured multi-point tee-to-flag route as the lowest locked Smart Component layer.
Read component guide →Hole spine
Connect tee, dogleg, and center green with two straight lowest-layer segments.
Read component guide →Fairway widths
Draw tee-shot-bearing widths at 220–260 carry yards or the full fairway-following 10-yard profile.
Read component guide →Annotation primitives
Build client-owned ideas from local pixels.
Image, shape, and text Annotations never call the protected sidecar. The client supplies their starting image pixels and the SDK supplies the shared component behavior.
Image annotation
Place a client-hosted HTTPS PNG at a client-provided image pixel.
Read primitive guide →Shape annotation
Add a local circle, square, or diamond without loading another asset.
Read primitive guide →Text annotation
Place a short client-authored text block directly in the component layer.
Read primitive guide →Shared view API
Build your own controls around the mounted view.
Graphics JS does not prescribe a toolbar or editor UI. Your application owns the controls and calls the view methods that correspond to its product experience.
await view.setSmartComponents([
{ type: "tee", movable: true },
{ type: "flag", movable: false },
]);
await view.addSmartComponent({
id: "approach-100",
type: "approach-markers",
yardages: [100],
style: { color: "#FF0000" },
});
await view.addSmartComponent({
id: "approach-150",
type: "approach-markers",
yardages: [150],
style: { color: "#FFFFFF" },
});
// All of these update the local DOM without rendering another image.
view.setSmartComponentVisible("tee", false);
view.setSmartComponentMovable("flag", true);
view.setSmartComponentStyle({ type: "flag", style: { size: 56 } });
view.resetSmartComponentPosition("tee");
// Client-authored primitives use client-provided image pixels.
view.setAnnotations([{
type: "annotation",
id: "preferred-miss",
position: { x: 420, y: 610 },
movable: true,
content: { type: "shape", shape: "diamond" },
}]);setSmartComponents removes absent components locally, retains unchanged placements and DOM, and requests only new or placement-affecting definitions. Types may repeat, up to 64 total instances per request. Give repeated instances explicit id values when later controls should target only one; a type selector continues to affect every instance of that type. addSmartComponent and removeSmartComponent provide incremental equivalents. Identical removed definitions are restored from the mounted view's bounded cache. Pass { force: true } as the options argument only when every requested definition must be resolved again. The earlier setOverlays and setOverlay* names remain compatibility aliases during the beta.
Shared events
Connect components to application behavior.
| Event | When it fires | Detail |
|---|---|---|
| caddie100:overlayclick | A marker or Shot dispersion endpoint is activated without completing a drag. | placement |
| caddie100:overlaypositionchange | A movable marker is dragged, moved by keyboard, or reset. | placement, originalPosition, source |
| caddie100:shotdispersionpositionchange | One Shot dispersion endpoint is dragged, moved by keyboard, or reset. | placement, endpoint, originalPosition, source |
| caddie100:overlayimagestatus | A custom marker PNG loads or fails. | id, type, url, status |
| caddie100:componentclick | A point marker, Shot dispersion endpoint, or Annotation is activated. | source, placement |
| caddie100:componentpositionchange | A movable point marker or Annotation is dragged, moved by keyboard, or reset. | source, placement, originalPosition, sourceAction |
| caddie100:componentimagestatus | An Image Annotation PNG loads or fails. | source, id, url, status |