lustre_kakaomap/geojson
GeoJSON coordinate helpers for KakaoMap shapes.
Converts GeoJSON [longitude, latitude] coordinate pairs to LatLng. GeoJSON uses [lng, lat] order — this module handles the swap automatically. Pure Gleam, no FFI required.
Values
pub fn coord_pair(
lng lng: Float,
lat lat: Float,
) -> coords.LatLng
Converts a GeoJSON [lng, lat] pair to LatLng. GeoJSON uses longitude-first order; LatLng uses latitude-first.
geojson.coord_pair(lng: 126.978, lat: 37.5665)
// -> coords.lat_lng(lat: 37.5665, lng: 126.978)
pub fn draw_line_string(
coordinates coordinates: List(coords.LatLng),
id id: String,
shape_id shape_id: String,
options extra_options: List(polyline.PolylineOption),
) -> effect.Effect(msg)
Draws GeoJSON LineString coordinates as a polyline on the map.
let coords = geojson.line_coords([#(126.978, 37.566), #(129.042, 35.114)])
geojson.draw_line_string(coords,
id: "map", shape_id: "route",
options: [polyline.stroke_color("#FF0000")],
)
pub fn draw_polygon_ring(
coordinates coordinates: List(coords.LatLng),
id id: String,
shape_id shape_id: String,
options extra_options: List(polygon.PolygonOption),
) -> effect.Effect(msg)
Draws GeoJSON Polygon coordinates as a polygon on the map. The first ring is the outer boundary.
let ring = geojson.line_coords([#(127.0, 37.0), #(127.1, 37.0), #(127.05, 37.1), #(127.0, 37.0)])
geojson.draw_polygon_ring(ring,
id: "map", shape_id: "area",
options: [polygon.fill_color("#00FF00"), polygon.fill_opacity(0.3)],
)
pub fn line_coords(
pairs: List(#(Float, Float)),
) -> List(coords.LatLng)
Converts a list of GeoJSON [lng, lat] tuples to a LatLng list. Useful for LineString and Polygon ring coordinates.
geojson.line_coords([#(126.978, 37.566), #(129.042, 35.114)])