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 🙏

© 2024 – Pkg Stats / Ryan Hefner

maplibre-gl-inspect

v0.0.6

Published

Mapbox layer for average/interpolation heatmaps

Downloads

64

Readme

Maplibre GL Inspect

GitHub Workflow Status GitHub Workflow Status GitHub Workflow Status GitHub release (latest SemVer) npm DeepScan grade GitHub contributors npm type definitions npm npm npm bundle size (version)

vite maplibre-gl husky eslint prettier typescript

Maplibre GL Inspect is a fork of @acalcutt's Maplibre GL Inspect which is a fork of @lukasmartinelli Mapbox GL Inspect. This fork is typescriptified along with strict ESLint & Prettier rule(s) in place for code standardisation 🕺

Add an inspect control to maplibre-gl-js to view all features of the vector sources and allows hovering over features to see their properties.

Requires maplibre-gl-js (min version 1.15).

Maplibre GL Inspect Preview

Usage

maplibre-gl-inspect is a Maplibre GL JS plugin that you can easily add on top of your map. Check index.html for a complete example.

Make sure to include the CSS and JS files.

When using a CDN

<script src='https://unpkg.com/maplibre-gl-inspect@latest/dist/maplibre-gl-inspect.js'></script>
<link href='https://unpkg.com/maplibre-gl-inspect@latest/dist/maplibre-gl-inspect.css' rel='stylesheet' />

When using modules

require('maplibre-gl-inspect/dist/maplibre-gl-inspect.css');
var maplibregl = require('maplibre-gl');
var MaplibreInspect = require('maplibre-gl-inspect');

// Pass an initialized popup to Maplibre GL
map.addControl(new MaplibreInspect({
  popup: new maplibregl.Popup({
    closeButton: false,
    closeOnClick: false
  })
}));

Add Inspect Control

Add the inspect control to your map.

map.addControl(new MaplibreInspect());

Show Inspection Map

Switch to the inspection map by default.

map.addControl(new MaplibreInspect({
  showInspectMap: true
}));

Show only Inspection Mode

Switch to the inspection map by default and hide the inspect button to switch back to the normal map. Check examples/inspect-only.html

map.addControl(new MaplibreInspect({
  showInspectMap: true,
  showInspectButton: false
}));

Disable Popup

Disable the feature Popup in inspection mode and in map mode. Check examples/no-popup.html

map.addControl(new MaplibreInspect({
  showInspectMapPopup: false,
  showMapPopup: false
}));

Custom Popup Function

You can also control the Popup output. Check examples/custom-popup.html

map.addControl(new MaplibreInspect({
  renderPopup: function(features) {
    return '<h1>' + features.length + '</h1>';
  }
}));

Custom Color Function

You are able to control the generated colors and background of the inspection style. Check examples/custom-color-1.html and examples/custom-color-2.html.

var colors = ['#FC49A3', '#CC66FF', '#66CCFF', '#66FFCC'];
map.addControl(new MaplibreInspect({
  backgroundColor: '#000',
  assignLayerColor: function(layerId, alpha) {
    var randomNumber = parseInt(Math.random() * colors.length);
    return colors[randomNumber];
   }
}));

Show just Popup but no Inspect Style

You can also hide the inspect button and enable the popup on the map if just want the popup hovering feature in your normal map but no inspect style. Check examples/no-inspect-style.html.

map.addControl(new MaplibreInspect({
  showInspectButton: false,
  showMapPopup: true
}));

Show Popup only for certain Features

You can pass a queryParameters object structured like the parameters object documented for map.queryRenderedFeatures](https://maplibre.org/maplibre-gl-js-docs/api/map/#map#queryrenderedfeatures). This let's you show the inspect popup for only certain layers. Check examples/query-params.html.

map.addControl(new MaplibreInspect({
  queryParameters: {
    layers: ['composite_road_line']
  }
}));

You can also use this feature to do custom layer filtering.

map.addControl(new MaplibreInspect({
  queryParameters: {
    filter: ['>', 'height', 10]
  }
}));

Less Fidly Popup

If inspecting features is too fiddly for thin lines you can optionally set a custom pixel buffer around the pointer when querying for features to make inspection a bit more forgiving. Check examples/less-fidly.html.

map.addControl(new MaplibreInspect({
  selectThreshold: 50
}));

Show Popup only on Click not on Hovering

Do not show the inspect popup when hovering over the map but only when clicking on the map. Check examples/popup-on-click.html.

map.addControl(new MaplibreInspect({
  showMapPopup: true,
  showMapPopupOnHover: false,
  showInspectMapPopupOnHover: false
}));

Add a Callback for Inspect Toggle Events

Call a function whenever the user toggles the inpect map on or off. Useful for adding inspect state to URL hash. Check examples/url-hash-toggle-callback.html.

map.addControl(new MaplibreInspect({
  toggleCallback: function(showInspectMap) { 
    console.log(`showInspectMap is ${showInspectMap}`);
  }
}));

Develop

Create a minified standalone build.

npm install
npm run build