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

@daturon/mapboxgl-layer-manager

v1.2.3

Published

The Layer Manager for Mapbox GL is a versatile and user-friendly tool designed to streamline the management of map layers within the Mapbox GL environment. This tool simplifies the process of modifying layer order and adjusting and fine-tuning each layer'

Downloads

419

Readme

Mapbox GL Layer Manager

npm version

The Layer Manager for Mapbox GL is a powerful utility that simplifies the management of layers and sources in the Mapbox GL environment. This package allows easy layer reordering, visibility toggling, opacity adjustments, and other modifications, making it an essential tool for developers working with interactive maps.

It supports dynamic management of multiple sources and layers, allowing developers to dynamically change active sources, reorder layers efficiently, and automatically free unused resources to optimize performance.


Features

  • Easy Layer and Source Management – Add, remove, and update layers and sources effortlessly.
  • Dynamic Layer Reordering – Change layer positions in real-time.
  • Customize Layer Styling – Adjust opacity, visibility, and colors dynamically.
  • Manage Multiple Sources – Attach and detach different sources on the fly.
  • Automatic Resource Cleanup – Unused sources and layers are removed automatically to improve efficiency.
  • Advanced Filtering System – Filters have unique identifiers, making them easy to enable/disable dynamically.

Installation

You can install the package via npm or yarn:

npm install @daturon/mapboxgl-layer-manager

or

yarn add @daturon/mapboxgl-layer-manager

Usage

1️⃣ Import and Initialize

import { LayerManager } from '@daturon/mapboxgl-layer-manager';

const map = new mapboxgl.Map({
  container: 'map',
  style: 'mapbox://styles/mapbox/streets-v11',
  center: [-74.006, 40.7128],
  zoom: 10,
});

const manager = new LayerManager(map);

2️⃣ Add a Layer with a Source

manager.addSource('my-source', {
  type: 'geojson',
  data: myGeoJSONData,
});

manager.addLayer({
  id: 'my-layer',
  type: 'circle',
  source: 'my-source',
  paint: { 'circle-radius': 5, 'circle-color': '#ff0000' },
});

manager.renderOrderedLayers(['my-layer']); // When we have multiple layers, we can use the renderOrderedLayers method to render them in the correct order. Call this method again when you need a new layer set to be rendered.

3️⃣ Modify Layer Properties

manager.setLayerOpacity('my-layer', 0.5);
manager.toggleLayerVisibility('my-layer');

4️⃣ Reorder Layers

manager.reorderLayer('my-layer', 'another-layer');

5️⃣ Manage Filters Dynamically

manager.setFilter('my-layer', 'my-filter', ['==', 'type', 'park']);
manager.removeFilter('my-layer', 'my-filter');

6️⃣ Remove a Layer and Free Resources

manager.removeLayer('my-layer');
manager.removeSource('my-source');

Watch the demo


Contributing

We welcome contributions! If you want to improve this package:

  1. Fork the repository.
  2. Clone your fork:
    git clone https://github.com/daturon/mapboxgl-layer-manager.git
  3. Install dependencies:
    yarn install
  4. Create a feature branch:
    git checkout -b feature-name
  5. Commit changes:
    git commit -m "Add new feature"
  6. Push and open a pull request.

License

This project is licensed under the MIT License.


Links

Happy Mapping!