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

landjepik

v0.1.0

Published

Static map images from OpenStreetMap or Kartverket with a marker — React component and server handler

Readme

landjepik

Generates static map images from OpenStreetMap or Kartverket tiles, with a single marker. In the browser as a React component (composed on a canvas), or on the server as a Vercel function.

Install

npm install landjepik
import { StaticMap } from 'landjepik'
import 'landjepik/style.css'

<StaticMap lat={59.9139} lon={10.7522} zoom={14} width={600} height={400} />

<StaticMap
  lat={60.3913}
  lon={5.3221}
  zoom={12}
  width={300}
  height={200}
  marker={{ color: '#2563eb', size: 32 }}
  format="image/jpeg"
  onRender={(blob) => console.log(blob)}
/>

Without React:

import { renderStaticMap, renderStaticMapBlob } from 'landjepik'

const blob = await renderStaticMapBlob({ lat: 59.9139, lon: 10.7522, zoom: 14, width: 600, height: 400 })
const canvas = await renderStaticMap({ lat: 59.9139, lon: 10.7522, zoom: 14, width: 600, height: 400 })

Options

| Option | Default | Description | | ------------- | ----------------------------------------------- | ----------------------------------------------------- | | lat, lon | – | Map center | | zoom | – | Integer zoom level, 0–19 | | width, height | – | Image size in pixels | | scale | 1 | Pixel density. 2 = 2× image, displayed at width × height | | provider | osm | Built-in tile source, see below | | maxZoom | from provider | Highest zoom the tile source offers | | marker | true | true = at center, false = none, or { lat, lon, color, size } | | tileUrl | from provider | Tile URL template (server must send CORS headers) | | attribution | from provider | Text drawn bottom right, or false | | background | #ddd | Fill where no tiles exist | | format | image/png | Component only: output image type |

Tile providers

| provider | Map | Coverage | Max zoom | Attribution | | ------------------- | -------------------------------------- | -------- | -------- | ------------------------------ | | osm | OpenStreetMap standard | World | 19 | © OpenStreetMap contributors | | kartverket | Kartverket topographic (norgeskart) | Norway | 18 | © Kartverket | | kartverket-grey | Kartverket topographic, grey tones | Norway | 18 | © Kartverket | | kartverket-raster | Kartverket raster (N50 style) | Norway | 18 | © Kartverket | | kartverket-sea | Kartverket nautical chart | Norway | 18 | © Kartverket |

<StaticMap provider="kartverket" lat={59.9139} lon={10.7522} zoom={14} width={600} height={400} />

Kartverket data is open (CC BY 4.0) and free to use, also commercially, with attribution. tileUrl, attribution and maxZoom override the provider's values. Zoom above maxZoom upscales the deepest tiles.

Sharp images on retina screens

Opt-in. With scale: 2 the canvas is rendered at double resolution. For tile sources without retina tiles (like OSM) tiles from one zoom level deeper are used: sharp, but map labels look smaller. If your tile source has @2x tiles, put {r} in tileUrl and it is used instead, e.g. https://a.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png (Carto has its own terms and attribution).

Note: the public OSM tile server has a usage policy — use your own tile source via tileUrl for heavy traffic.

Server / Vercel function

landjepik/server renders the same image in Node, e.g. as a Vercel serverless function — like a self-hosted static map API. It needs the optional peer dependency @napi-rs/canvas:

npm install landjepik @napi-rs/canvas
// api/staticmap.ts
import { staticMapHandler } from 'landjepik/server'

export const GET = (request: Request) =>
  staticMapHandler(request, {
    // OSM's tile policy requires an identifying User-Agent
    userAgent: 'my-app/1.0 (+https://example.com)',
  })
<img src="/api/staticmap?lat=59.9139&lon=10.7522&zoom=14&width=600&height=400" width="600" height="400" alt="Map" />

Use the Node.js runtime (not Edge — @napi-rs/canvas is a native module).

| Query param | Default | Description | | ---------------------- | ------- | --------------------------------------------------- | | lat, lon, zoom | – | Required | | width, height | 600×400 | Max 1280 (maxSize handler option) | | scale | 1 | 1–3 | | provider | osm | See tile providers above | | marker | on | false/0/none hides it | | color, markerSize | e11d48, 40 | Hex color without # | | markerLat, markerLon | center | Marker position | | format, quality | png, 85 | png, jpeg or webp |

Responses get Cache-Control: public, max-age=86400, s-maxage=2592000, stale-while-revalidate=86400, so Vercel's CDN serves repeated requests without re-rendering (override with cacheControl). Tile URLs can't be set from the query string. Restrict providers with providers: ['kartverket']. Lower-level building blocks: renderStaticMapImage(options, { format }) returns a Buffer, and parseStaticMapParams(searchParams) parses the query.

Development

npm install
npm run dev        # playground at http://localhost:5173 (dev/main.tsx), with HMR
npm test           # vitest
npm run typecheck
npm run build      # outputs ESM + .d.ts + CSS to dist/
npm publish        # runs typecheck, tests and build first

The bundled Inter font (used for attribution text on the server) is licensed under the SIL Open Font License 1.1, see src/fonts/Inter-LICENSE.txt.