Drawing & editing tools for Leaflet
Vectorstream adds drawing and editing tools to your web map. Draw, edit, move, rotate and snap shapes, then read everything back as GeoJSON.
Core toolkit
Twelve features of the editor.
A selection from vectorstream. The features page lists every tool and behaviour, grouped by task.
Beyond drawing
The details that make GIS editing feel right.
Snapping
New points snap onto nearby corners and edges while you draw. Hold Alt to turn snapping off.
Live measurements
While you draw a polygon, the length of the current side, the perimeter and the area update with every move of the pointer.
Cut
Draw a shape across the outer edge of an area and the cut tool removes the strip it covers. The strip does not stay as a shape, and a shape in the middle of an area is rejected.
Union
The union tool merges areas that share at least one edge into one area. Areas that are not neighbours are rejected.
Lasso
Draw a loop with the lasso to select areas. Every area the loop encloses completely is selected; an area it only crosses is not.
Integration
Add the editor to your map, listen for events.
Vectorstream hooks into the map you already have. Every edit ends in one of three events: change, unchanged or rejected.
The packages are not published yet. These excerpts are taken from the quickstarts in the docs.
import L from 'leaflet';
import { exportGeoJSON, importGeoJSON, type FeatureCollection } from '@vectorstream/core';
import { Editor, Toolbar, defaultToolbarEntries } from '@vectorstream/editor';
import { LeafletAdapter } from '@vectorstream/leaflet';
export function startEditor(container: HTMLElement, data: FeatureCollection) {
const map = L.map(container).setView([51.5112, 7.4555], 17);
const adapter = new LeafletAdapter(map);
const editor = new Editor(importGeoJSON(data), adapter);
const toolbar = new Toolbar(editor, defaultToolbarEntries());
toolbar.select('draw');
editor.on('change', ({ label }) => console.log('changed:', label));
editor.on('unchanged', ({ label }) => console.log('nothing to do:', label));
editor.on('rejected', ({ label, violations }) => {
console.warn('rejected:', label, violations.map((v) => v.detail));
});
return {
editor,
save: (): FeatureCollection => exportGeoJSON(editor.partition),
};
}Solutions
Built for work where neighbours share a border.
Parcels, zones, stands and lease areas: see how each field uses vectorstream.
Pricing
Free for the editor, Pro for the rules.
Every tool and the topology are free under the MIT license. Pro adds ten more kinds of rule between layers, the red preview, the list of violations and more. Pro is priced on request.
FAQ
Questions
The questions asked most often. Every other answer is on the FAQ page.