npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sindicum/libre-draw

v0.3.1

Published

MapLibre GL JS polygon drawing and editing library

Readme

LibreDraw

npm version License: MIT

A polygon drawing and editing library for MapLibre GL JS.

Features

  • Zero-confignew LibreDraw(map) gives you a full toolbar and drawing capabilities out of the box
  • Draw polygons — Click/tap to place vertices, double-click/double-tap to finish
  • Select & edit — Click a polygon to select it, drag vertices to reshape, drag midpoints to add vertices
  • Polygon drag — Drag an entire selected polygon to reposition it
  • Split polygon — Cut a polygon into two polygons with a two-point split line
  • Setback edge — Offset a selected edge inward and remove the setback band
  • Undo / Redo — Full history support for all operations
  • GeoJSON in/out — Import and export standard GeoJSON FeatureCollections
  • Touch-first — Designed for mobile with proper touch targets (44px+), long-press support, and gesture handling
  • Self-intersection prevention — Invalid geometries are rejected during editing
  • Framework-agnostic — Works with vanilla JS, React, Vue, or any framework
  • TypeScript — Full type definitions included
  • Headless mode — Disable the toolbar and drive everything via API

Quick Start

npm install @sindicum/libre-draw maplibre-gl
import maplibregl from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
import { LibreDraw } from '@sindicum/libre-draw';

const map = new maplibregl.Map({
  container: 'map',
  style: 'https://demotiles.maplibre.org/style.json',
  center: [0, 0],
  zoom: 2,
});

const draw = new LibreDraw(map);

draw.on('create', (e) => {
  console.log('Polygon created:', e.feature);
});

draw.on('update', (e) => {
  console.log('Polygon updated:', e.feature);
});

API

Constructor

new LibreDraw(map: maplibregl.Map, options?: LibreDrawOptions)

Methods

| Method | Description | | ------------------------- | ----------------------------------------------------- | | setMode(mode) | Set active mode: 'idle', 'draw', 'select', 'split', or 'setback' | | getMode() | Get the current mode | | getFeatures() | Get all features as an array | | toGeoJSON() | Export all features as a GeoJSON FeatureCollection | | getFeatureById(id) | Get a single feature by ID | | setFeatures(geojson) | Replace all features with a GeoJSON FeatureCollection | | addFeatures(features) | Add an array of GeoJSON Feature objects | | deleteFeature(id) | Delete a feature by ID (undoable) | | selectFeature(id) | Programmatically select a feature | | clearSelection() | Clear the current selection | | getSelectedFeatureIds() | Get IDs of selected features | | undo() | Undo the last action | | redo() | Redo the last undone action | | on(event, callback) | Register an event listener | | off(event, callback) | Remove an event listener | | destroy() | Clean up all resources |

Events

| Event | Payload | Description | | ----------------- | -------------------------------------------------- | ------------------------------------ | | create | { feature } | A polygon was created | | update | { feature, oldFeature } | A polygon was updated | | delete | { feature } | A polygon was deleted | | split | { originalFeature, features: [featureA, featureB] } | A polygon was split into two polygons | | splitfailed | { reason, featureId } | Split operation failed | | setback | { originalFeature, feature, edgeIndex, distance } | Setback operation succeeded | | setbackfailed | { reason, featureId } | Setback operation failed | | selectionchange | { selectedIds } | Selection changed | | modechange | { mode, previousMode } | Active mode changed |

Options

interface LibreDrawOptions {
  toolbar?:
    | boolean
    | {
        position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
        controls?: {
          draw?: boolean;
          select?: boolean;
          split?: boolean;
          setback?: boolean;
          delete?: boolean;
          undo?: boolean;
          redo?: boolean;
        };
      };
  historyLimit?: number; // Default: 100
}

Set toolbar: false for headless mode (API-only, no UI).

Documentation

Full documentation with interactive demos is available at:

https://sindicum.github.io/libre-draw/

Development

# Install dependencies
npm install

# Run dev server with example
npm run dev

# Run tests
npm test

# Lint
npm run lint

# Type check
npm run typecheck

# Build
npm run build

# Documentation site
npm run docs:dev

Requirements

  • MapLibre GL JS >= 3.0.0, v3.x and v4.x supported (peer dependency)
  • Modern browser with WebGL support

License

MIT