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

datocms-plugin-geojson-polygons

v1.1.2

Published

Draw and edit GeoJSON polygons on a map inside a DatoCMS JSON field.

Readme

GeoJSON Polygons for DatoCMS

GeoJSON Polygons cover

Draw and edit polygons on a map inside a DatoCMS JSON field. Editors outline delivery zones, service areas, venues, neighborhoods, campuses, or sales territories, and the field stores standard GeoJSON that any frontend can render.

One field can hold many polygons. Each locale of a localized field keeps its own set. There is no API key and no map billing: the map uses MapLibre GL with OpenFreeMap tiles.

Demo

Drawing, editing, importing, and switching basemaps in the polygon field

The demo draws a polygon point by point, drags a vertex, inserts a point on an edge, undoes a step, switches to the satellite basemap, imports coordinates, and fits the map to every shape. Watch the full-quality MP4.

On the DatoCMS Marketplace, that recording plays in the preview above this README. The player comes from datoCmsPlugin.previewImage in package.json, which points at docs/demo.mp4 inside the published package. The README keeps the GIF, the same split official plugins use.

What editors see

Polygon field editor preview

  • Right-click the map to add a point. On touch devices, tap instead.
  • Drag a vertex to move it. Right-click a vertex to remove it.
  • Right-clicking near an edge of a closed polygon inserts a point on that edge.
  • Close shape turns three or more points into a polygon. Only closed polygons are saved.
  • New polygon starts another shape. A field can hold as many polygons as you need.
  • Click a polygon, or its button below the map, to select it. The table lists the selected polygon's latitude and longitude pairs.
  • Undo reverts the last change, one step at a time, including drags and deletions.
  • Import accepts GeoJSON (FeatureCollection, Feature, Polygon, MultiPolygon, LineString), raw coordinate arrays, or one longitude, latitude pair per line, with a blank line between shapes.
  • A layers button on the map switches between the Bright, Liberty, Dark, and Satellite basemaps.
  • Vertex dots grow and shrink with the zoom, and stay small enough that a dense outline remains readable. The click target is larger than the dot, so dragging and removing a point stays easy.

Scroll-wheel zoom needs Ctrl or ⌘ held down, and touch panning needs two fingers, so scrolling the record form never moves the map by accident.

Stored value

The field saves a GeoJSON FeatureCollection of Polygon features:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [-9.1508, 38.7105],
            [-9.1432, 38.7089],
            [-9.1368, 38.7118],
            [-9.1482, 38.7172],
            [-9.1508, 38.7105]
          ]
        ]
      }
    }
  ]
}
  • Positions are [longitude, latitude], as the GeoJSON spec requires.
  • Each ring is closed: its first and last positions are equal.
  • Rings are counter-clockwise (RFC 7946). Clockwise drawings are reversed on save.
  • When every polygon is removed, the field is set to null.
  • Holes are not supported. When you import a polygon that has holes, only its outer ring is kept.

Because this is plain GeoJSON, you can pass it straight to MapLibre, Mapbox, Leaflet, Google Maps Data layers, Turf.js, or PostGIS.

Setup

  1. Install the plugin from the DatoCMS Marketplace, or add it as a private plugin using https://plugins-cdn.datocms.com/datocms-plugin-geojson-polygons@latest/dist/index.html.
  2. Optionally, open the plugin settings to choose the default map center, zoom, and basemap. These apply when a field is empty. The default is Lisbon at zoom 12.
  3. Add a JSON field to a model. Under Presentation, choose the GeoJSON polygons editor.

Localized fields work too: each locale keeps its own polygons.

Map data and licenses

Development

This project uses Node 22.12 or newer and pnpm 12, which you can enable with corepack enable.

pnpm install   # also copies the MapLibre worker into public/
pnpm dev       # http://localhost:5173, add as a private plugin in DatoCMS
pnpm check     # oxlint (no warnings allowed), vitest, and the production build

MapLibre runs its tile parsing in a module worker. scripts/copy-maplibre-worker.mjs copies maplibre-gl-worker.mjs and maplibre-gl-shared.mjs from the maplibre-gl package into public/. Vite then ships them next to index.html, and the worker URL is resolved relative to the document, so it also works from the versioned plugin CDN.

Stack

  • DatoCMS Plugin SDK 2.5 and datocms-react-ui 2.5
  • React 19, TypeScript 7 (strict), Vite 8
  • MapLibre GL 6
  • Oxlint and Vitest

Releasing

Publishing a GitHub release runs .github/workflows/publish.yml, which checks the project and publishes it to npm with the NPM_TOKEN repository secret. The package includes dist, the images in marketplace/, and docs/demo.mp4, which the Marketplace plays as the listing preview. DatoCMS picks up new versions automatically.

Credits

The drawing, editing, and import logic is adapted from GeoJSON Polygon Builder, a standalone Next.js tool (live demo).

License

MIT