Interactive area transform tool for MapLibre GL JS. Draw, move, resize, rotate, and optionally warp rectangles into quadrilaterals to capture precise lat/lng coordinates. Supports image overlay alignment and georeferencing workflows with real-time visual feedback.
https://mapmelabs.github.io/maplibregl-area-transform/
https://mapmelabs.github.io/maplibregl-area-transform/demo/
The below is still a work in progress...
yarn add maplibregl-area-transform
or
npm install maplibregl-area-transform
import maplibregl from 'maplibre-gl'
import AreaTransform from 'maplibregl-area-transform'
const map = new maplibregl.Map({
container: 'map',
style: 'https://demotiles.maplibre.org/style.json',
center: [0, 0],
zoom: 2
})
const tool = new AreaTransform({
// options
})
map.addControl(tool)
// listen to updates
tool.on('change', (coords) => {
console.log('Area coordinates:', coords)
})
[
[lng1, lat1],
[lng2, lat2],
[lng3, lat3],
[lng4, lat4]
]
| Option | Type | Default | Description |
|---|---|---|---|
quadrilateral |
boolean | false |
Enable free corner manipulation (non-rectangular shape) |
rotatable |
boolean | true |
Allow rotation of the area |
resizable |
boolean | true |
Allow scaling / resizing |
draggable |
boolean | true |
Allow moving the entire area |
image |
string | null |
URL of overlay image (optional) |
opacity |
number | 1.0 |
Opacity of the overlay image |
minSize |
number | 0 |
Minimum allowed size of the area (in pixels or map units) |
aspectRatio |
number | null |
Lock aspect ratio (e.g. 1 for square) |
| Event | Payload | Description |
|---|---|---|
start |
{ coordinates } |
Fired when user starts interaction |
change |
{ coordinates } |
Fired on any update (drag, resize, rotate, warp) |
end |
{ coordinates } |
Fired when interaction ends |
create |
{ coordinates } |
Fired when a new area is created |
delete |
null |
Fired when the area is removed |
• In quadrilateral mode, the shape may become non-rectangular and distort any attached image.
• Coordinates are returned in [lng, lat] format.
• Designed to work alongside existing MapLibre controls.