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

@prashis/maplibre-gl-controls

v1.0.1

Published

Controls for maplibre-gl

Downloads

92

Readme

Maplibre Controls

Preview

Usage

npm install maplibre-gl-controls

Include styles from package: maplibre-gl-controls/lib/controls.css

Ruler Control [options]

import { RulerControl } from 'maplibre-gl-controls';

map.addControl(new RulerControl(), 'top-right');
map.on('ruler.on', () => console.log('ruler: on'));
map.on('ruler.off', () => console.log('ruler: off'));

// with miles:
map.addControl(new RulerControl({
  units: 'miles',
  labelFormat: n => `${n.toFixed(2)} ml`,
}), 'top-right');

Styles Control [options]

Adds style switcher similar to Google Maps.

import { StylesControl } from 'maplibre-gl-controls';

// with default styles:
map.addControl(new StylesControl(), 'top-left');

// with custom styles:
map.addControl(new StylesControl({
  styles: [
    {
      label: 'Streets',
      styleName: 'Mapbox Streets',
      styleUrl: 'mapbox://styles/mapbox/streets-v9',
    }, {
      label: 'Satellite',
      styleName: 'Satellite',
      styleUrl: 'mapbox://styles/mapbox/satellite-v9',
    },
  ],
  onChange: (style) => console.log(style),
}), 'top-left');

Compass Control [options]

import { CompassControl } from 'maplibre-gl-controls';

map.addControl(new CompassControl(), 'top-right');

Zoom Control

import { ZoomControl } from 'maplibre-gl-controls';

map.addControl(new ZoomControl(), 'top-right');

Language Control [options]

Localize map. Language can be set dynamically with .setLanguage(lang) method.

import { LanguageControl } from 'maplibre-gl-controls';

// with browser detect:
map.addControl(new LanguageControl());

// with custom language:
const languageControl = new LanguageControl({
  language: 'ru',
});
map.addControl(languageControl);

// change language to multi language after control has been added:
languageControl.setLanguage('mul');

Inspect Control

Inspect control to debug style layers and source

Inspect Control

import { InspectControl } from 'maplibre-gl-controls';

map.addControl(new InspectControl(), 'bottom-right');

Tooltip Control [options]

Shows tooltip on hover on some layer or whole map.

Tooltip Control

import { TooltipControl } from 'maplibre-gl-controls';

map.addLayer({
  id: '$fill',
  type: 'fill',
  source: { type: 'geojson', data: polygon },
  paint: { 'fill-opacity': 0.3, 'fill-color': '#4264fb' },
});

map.addControl(new TooltipControl({ layer: '$fill' }));