New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

@maproll/map-url

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@maproll/map-url

The maproll map URL grammar: build and parse api.maproll.io map URLs.

latest
Source
npmnpm
Version
0.1.2
Version published
Weekly downloads
21
-89.66%
Maintainers
1
Weekly downloads
 
Created
Source

@maproll/map-url

The maproll map URL grammar: build an api.maproll.io map URL from parameters, and parse one back.

Every maproll map is a URL. This package is the single definition of how that URL is written and read, shared by the editor (app.maproll.io) and the MCP server (@maproll/mcp) so the two cannot drift.

Pure, dependency-free, isomorphic — browser, Node, and Workers.

import { buildUrl, parseUrl, serializeDataRows } from "@maproll/map-url";

const url = buildUrl({
  scope: "world",
  title: "Coffee consumption per capita",
  data: serializeDataRows([
    { kind: "value", id: "FI", value: 12 },
    { kind: "value", id: "US", value: 4.2 },
  ]),
});
// https://api.maproll.io/map.svg?scope=world&title=...&data=FI%3A12%2CUS%3A4.2

const { params, markers, routes } = parseUrl(url);

What's in it

ExportPurpose
buildUrl, buildEmbedParams → URL, or a ready <img> tag
parseUrl, parseMarkers, parseRoutes, hasMapParamsURL → params
applyPatchMerge a partial update (null clears, undefined leaves alone)
serializeDataRows, parseDataString, replaceColorRows, isHexColorThe four data= pair shapes
serializeMarkers, serializeRoutesLayer serialisation
SCOPES, GROUP_SCOPES, ALL_SCOPES, SCOPE_CODESScope catalog
MapParams, MarkerEntry, RouteEntry, DataRow, …Types

Design notes

Parsing is forgiving, but never silently wrong. A malformed marker or route is skipped so a hand-edited link still yields the map it mostly describes — but input that would parse into a plausible wrong value is rejected instead. Number("") is 0, so markers=10, would have put a marker on the equator; a route colour written without its # (008000) would have become a stroke width of 8000.

parseUrl only accepts known keys. buildUrl serialises whatever it is handed, so carrying unknown keys through would push a utm_source from a shared link into the render URL. A param added to the API is ignored here until MAP_PARAM_KEYS learns about it — add it in the same change.

Round-tripping preserves the map, not the string. parseUrl fills in defaults, so a minimal URL comes back with them spelled out. Key order is not stable; compare params, not URLs.

Scripts

npm run build      # tsc → dist/
npm test           # vitest
npm run typecheck

src/scopes.ts is generated from the editor's scope list; regenerate it when scopes change.

Keywords

maproll

FAQs

Package last updated on 22 Sep 2026

Related posts