feat: complete Tier 4 marker/popup options, events, and live drag (#1)
All checks were successful
CI / Build and Test (push) Successful in 38s
CI / Build and Test (pull_request) Successful in 36s

Add missing marker options (offset, scale, opacity, opacityWhenCovered,
className) and popup options (closeOnClick, closeOnMove, anchor, offset,
className).

Return MarkerHandle from AddMarker with OnClick, OnDragStart, OnDrag,
OnDragEnd event methods. Return PopupHandle from ShowPopup with OnOpen,
OnClose event methods.

Upgrade drag signal writeback to fire during drag (throttled via
requestAnimationFrame) in addition to dragend, enabling real-time
position sync across clients.
This commit is contained in:
Ryan Hamamura
2026-02-20 14:36:02 -10:00
parent 15fda48844
commit 1d57a0962a
4 changed files with 246 additions and 21 deletions

View File

@@ -324,6 +324,21 @@ type Marker struct {
// RotationSignal drives marker rotation reactively. When set, Rotation is ignored.
RotationSignal *via.Signal
// Offset is a pixel offset from the anchor point as [x, y].
Offset [2]float64
// Scale is a scaling factor for the default marker pin (0 = omit, MapLibre default 1).
Scale float64
// Opacity is the marker opacity 01 (0 = omit, MapLibre default 1).
Opacity float64
// OpacityWhenCovered is the marker opacity when behind 3D terrain (0 = omit).
OpacityWhenCovered float64
// ClassName is a CSS class added to the marker container element.
ClassName string
}
// Popup describes a map popup.
@@ -335,6 +350,23 @@ type Popup struct {
LngLat LngLat
HideCloseButton bool // true removes the close button (MapLibre shows it by default)
MaxWidth string
// CloseOnClick controls whether the popup closes on map click.
// nil = MapLibre default (true).
CloseOnClick *bool
// CloseOnMove controls whether the popup closes on map move.
// nil = MapLibre default (false).
CloseOnMove *bool
// Anchor forces the popup anchor position ("top", "bottom", "left", "right", etc.).
Anchor string
// Offset is a pixel offset from the anchor as [x, y].
Offset [2]float64
// ClassName is a CSS class added to the popup container.
ClassName string
}
// --- Event data ---
@@ -354,14 +386,40 @@ type sourceEntry struct {
js string
}
// MarkerHandle is returned by AddMarker and allows subscribing to marker events.
type MarkerHandle struct {
markerID string
m *Map
events []markerEventEntry
}
type markerEventEntry struct {
event string
signal *via.Signal
}
type markerEntry struct {
id string
marker Marker
handle *MarkerHandle
}
// PopupHandle is returned by ShowPopup and allows subscribing to popup events.
type PopupHandle struct {
popupID string
m *Map
events []popupEventEntry
}
type popupEventEntry struct {
event string
signal *via.Signal
}
type popupEntry struct {
id string
popup Popup
id string
popup Popup
handle *PopupHandle
}
type eventEntry struct {