Docs

@klorad/engine-openlayers

The scene as a 2D plan with OpenLayers. A reader like the three.js one, drawing the same World from above.

import { createMapRenderer } from "@klorad/engine-openlayers";
import { MapView } from "@klorad/engine-openlayers/react";

Peer dependencies: ol 10; react and @klorad/react for MapView.

ExportKindDescription
createMapRenderer(options)functionDraws the scene as a plan into container. Returns a MapRenderer.
MapView (/react)componentThe plan as a React component; reads the scene from KloradProvider unless given one, and needs no provider when given one. A ref gives frame, view and footprint.
defaultMapPalette, defaultMapStylevalueThe default colours and style: correspondence by colour, a shadow or twin without a fresh reading in grey, the selected one outlined.
MapPalette, MapLook, MapStyleContext, MapStyleFntypeFor objectStyle.
planShape(object, cs)functionAn object as a shape on a plan in longitude and latitude: an area, a line with a width, or a point.
openLayersCapabilitiesvalueWhat this reader draws: every kind from above, a model as a symbol, two dimensions.

What it draws

GeometryOn the plan
extrusion, polygonThe footprint, turned by the object's heading and sized by its scale.
boxIts footprint, width by depth.
cylinder, sphereA circle of its radius.
polylineThe path, as wide as its width in metres at every zoom.
markerA dot at its position.
modelA symbol at its position: the model's outline lives in its file.

Options

Prop

Type

MapRenderer

MemberDescription
select(objectId | null)Outlines an object; selection is your state, not the world's.
frame(objectIds?)Fits the plan to the given objects, or to all of them.
view()The centre, zoom and metres per pixel.
footprint()The area in view, as a box on Earth.
dispose()Stops drawing and removes the map.

Something wrong or unclear? Tell us.