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

maplibre-gl-map-to-image

v1.2.0

Published

A plug in for maplibregljs that captures a map canvas along with overlays and converts it to a raster image.

Readme

maplibre-gl-map-to-image

npm install maplibre-gl-map-to-image --save

A JavaScript library that generates an HTML image element with a PNG source from a Maplibre GL JS map. The library allows users to customize the map image by selecting which overlays to include or exclude, such as markers, popups, and controls. It also allows the map to fit a bounding box only for the purpose of image generation.

Features

  • Generate a PNG image from a Maplibre GL JS map
  • Customize the image by selecting which overlays to include:
    • Markers
    • Popups
    • Controls
  • Render overlays outside of the main Maplibre WebGL canvas context
  • Set the source of an existing HTML img element to the generated PNG data

Future Development

  • Direct access to image data for use cases like direct downloading
  • Support different image resolutions and aspect ratios that may not match the current map canvas

Dependencies

Usage

To use this library, simply call the toPng function and pass in your Maplibre GL JS map instance, along with options for which overlays to include. The function will return a PNG image that can be set as the source of an existing HTML img element.

import { toElement } from 'maplibre-gl-map-to-image';

const map = new maplibregl.Map({
  // your map options here
});

const targetImage = document.getElementById('target-image');

const options = {
    targetImageId, //* @param {string} REQUIRED: The ID of the target image element where the PNG will be set.
    [bbox], //* @param {array} Optional bounding box to fit the map before conversion. Default: null
    coverEdits, //* @param {boolean} Optional flag to hide changes made to the map while preparing the image. Eg. Setting it to a different bounding box. Default: true 
    hideAllControls, //* @param {boolean} Optional flag to hide all map controls during conversion. Default: false
    [hideControlsInCorner], //* @param {array} Optional specific corners to hide controls from. Default: []
    hideMarkers, //* @param {boolean} Optional flag to hide markers during conversion. Default: false
    hidePopups, //* @param {boolean} Optional flag to hide popups during conversion. Default: false
    [hideVisibleLayers], //* @param {array} Optional layer IDs to hide during conversion. Default: []
    [showHiddenLayers], //* @param {array} Optional layer IDs to show during conversion. Default: []
}

await toElement(map, options);

Demo

Source for the demo is in the ./demo folder. To run the demo from the project root folder:

npm install
npm run demo

Check localhost:5173