feat(maplibre): MapLibre GL plugin — interactive maps driven from Go#91
Merged
Conversation
Add plugins/maplibre, a MapLibre GL JS v5 plugin mirroring the echarts design: the plugin injects the CDN JS + (required) CSS and a per-page map registry, and a *Map drives the camera, markers, and GeoJSON data layers from Go over SSE. - Construction: center/zoom/pitch/bearing, zoom range, max bounds, navigation/scale/geolocate/fullscreen controls, GeoJSON sources + layers, and a WithMapOption escape hatch. - Camera: FlyTo/EaseTo/JumpTo/SetCenter/SetZoom/SetPitch/SetBearing/FitBounds. - Markers: keyed AddMarker/MoveMarker/RemoveMarker/ClearMarkers with Color/Draggable/Scale and XSS-safe PopupText (plus trusted-only PopupHTML). - Data: GeoJSON + layer builders; SetGeoJSON/AddGeoJSONSource/AddLayer/ SetPaintProperty/SetLayerVisibility/RemoveLayer(AndSource), guarded by a re-arming style-load wait. - Lifecycle: SetStyle/Resize/Dispose and a Call escape hatch. Add internal/examples/maps (server-driven world map) and document the plugin in docs/plugins.md.
joaomdsg
force-pushed
the
feat/maplibre-plugin
branch
2 times, most recently
from
June 3, 2026 19:13
5545c7a to
293e99b
Compare
…coords
Build the plugin into a full interactive-map toolkit, all driven from Go.
Inbound events: OnClick, OnMoveEnd, OnMarkerClick, OnMarkerDragEnd,
OnFeatureClick, and a generic OnMapEvent escape hatch route browser gestures
to bound methods, read via Map.Event(ctx). Handlers use the via.Action
func-union constraint (no public `any`). Every gesture carries the live camera
(zoom/bearing/pitch). WithFeatureHover highlights features client-side via
feature-state; clickable markers/features show a pointer cursor.
Styling: typed expression builders (Get, FeatureState, Zoom, Boolean, Case,
Interpolate, Step) plus WhenHovered/WhenState sugar replace hand-written
[]any expression trees.
Coordinates: LngLat{Lng,Lat} + At() and Bounds{West,South,East,North} replace
bare float pairs to defuse the lng/lat and bbox swap foot-guns; MapEvent.LngLat()
flows a gesture straight into the camera/marker APIs. WithMarker declares static
markers at construction (no OnConnect); GenerateFeatureIDs assigns feature ids
for feature-state.
Dialogs: ShowPopup / ShowPopupHTML / ClosePopup show keyed, server-driven
popups. The HTML variant and marker PopupHTML take an h.H, so popup bodies
compose with the same h.* builders (h.T escapes user data; only h.Raw is raw).
Inbound-event signals use a non-underscore namespace (datastar drops
_-prefixed local signals). Multi-map pages are isolated by per-map registry
slots. Documented in doc.go and demonstrated in internal/examples/maps.
joaomdsg
force-pushed
the
feat/maplibre-plugin
branch
from
June 3, 2026 19:20
293e99b to
64220ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
plugins/maplibre: a MapLibre GL JS v5 plugin for building interactive map applications driven entirely from Go over SSE — no client JavaScript.What's included
NewMapwith center/zoom/pitch/bearing, controls, GeoJSON sources + layers,WithMarkerstatic markers,GenerateFeatureIDs. Coordinates are typed —LngLat{Lng,Lat}/At(lng,lat)andBounds{W,S,E,N}defuse the lng/lat & bbox swap foot-guns.FlyTo/EaseTo/JumpTo/SetCenter/FitBounds), markers (AddMarker/MoveMarker/RemoveMarker/ClearMarkers), GeoJSON data layers,Call/WithMapOptionescape hatches.OnClick,OnMoveEnd,OnMarkerClick,OnMarkerDragEnd,OnFeatureClick, and a genericOnMapEventescape hatch — bound methods (via thevia.Actionconstraint, no publicany) read a typedMapEventcarrying the live camera.Get/FeatureState/Zoom/Boolean/Case/Interpolate/Step) +WhenHovered/WhenStatesugar, replacing raw[]anytrees.WithFeatureHoverhighlights client-side via feature-state.ShowPopup/ShowPopupHTML/ClosePopup— keyed server-driven popups; the HTML variant and markerPopupHTMLtake anh.H, so bodies compose withh.*(h.Tescapes user data).Notes / safety
_-prefixed local signals (caught via browser testing; guarded by a unit test).setText/h.T; all inlined JS values are unicode-escaped viamustJSONso</script>can't break out.Verification
go test ./...),go vet,gofmtclean.Docs in
plugins/maplibre/doc.go; runnable demo ininternal/examples/maps.