Maps and WebGIS for MoonBit web apps: a typed API over the mbt-map npm package
moon add t-ujiie-g/mbtmap
npm install mbt-map # bundled by your app's bundler (Vite, esbuild, …)let tokyo = @mbtmap.lnglat(139.7671, 35.6812)
let map = @mbtmap.Map::new(
"map",
style=@style.Style::url("https://example.com/style.json"),
center=tokyo,
zoom=14.0,
)
map.on(Load, _ => {
map.add_source(
"places",
@style.geojson_source(data={
"type": "Feature",
"properties": { "kind": "station" },
"geometry": { "type": "Point", "coordinates": [tokyo.lng, tokyo.lat] },
}),
)
map.add_layer(
@style.circle(
"places",
source="places",
circle_radius=@expr.num(8.0),
circle_color=@expr.match_(
@expr.get("kind"),
[("station", @expr.color("#2166ac"))],
default=@expr.color("#d6604d"),
),
),
)
})
|> ignore
map.on_layer(Click, ["places"], e => map.fly_to(center?=e.lnglat, zoom=16.0)) |> ignorepub(all) enum EventType {
MouseDown
MouseUp
MouseOver
MouseOut
MouseMove
Click
DblClick
ContextMenu
MouseEnter
MouseLeave
Load
StyleData
SourceData
Render
Idle
Error
MoveStart
Move
MoveEnd
ZoomStart
Zoom
ZoomEnd
RotateStart
Rotate
RotateEnd
PitchStart
Pitch
PitchEnd
}#external
pub type JsValuepub struct Listener {
// private fields
}#external
pub type MapInstall
Download zipMaps and WebGIS for MoonBit web apps: a typed API over the mbt-map npm package