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-measures

v0.0.15

Published

Length and area measurements with linestrings and polygons

Downloads

1,063

Readme

maplibre-gl-measures

maplibre-gl-measures

A MapLibre GL JS plugin for taking length measures with lines and area measures with polygons.

It's working with MapLibre GL JS inspired by the great work done by mapbox/mapbox-gl-draw

Demo

You can rush to the demo here.

Getting started

To use this plugin you need to run:

npm install --save maplibre-gl-measures

and then, in your code use it as follows:


// Import it into your code
import MeasuresControl from 'maplibre-gl-measures';

// your map logic here...

// add the plugin
map.addControl(new MeasuresControl({ /** see options below for further tunning */}), "top-left");

Options

You can control the appearance, units by using the following:

options = {
            lang: {
                areaMeasurementButtonTitle: 'Measure area',
                lengthMeasurementButtonTitle: 'Measure length',
                clearMeasurementsButtonTitle:  'Clear measurements',
            },
            units: 'imperial', //or metric, the default
            unitsGroupingSeparator: ' ', // optional. use a space instead of ',' for separating thousands (3 digits group). Do not send this to use the browser default
            style: {
                text: {
                    radialOffset:  0.9,
                    letterSpacing: 0.05,
                    color: '#D20C0C',
                    haloColor: '#fff',
                    haloWidth: 0,
                    font: 'Klokantech Noto Sans Bold',
                },
                common: {
                    midPointRadius: 3,
                    midPointColor: '#D20C0C',
                    midPointHaloRadius: 5,
                    midPointHaloColor: '#FFF',
                },
                areaMeasurement: {
                    fillColor: '#D20C0C',
                    fillOutlineColor: '#D20C0C',
                    fillOpacity: 0.01,
                    lineWidth: 2,
                },
                lengthMeasurement: {
                    lineWidth: 2,
                    lineColor: "#D20C0C",
                },
            }
        };

map.addControl(new MeasuresControl(options));

Optional drawing event callbacks can be added to the options. The features drawn will be passed to the callback. Use optional callbacks like:


// Handle onRender
function featureRenderCallback(feature) {            
    console.log("Feature rendered:", feature);
}

// Handle onCreate
function featureCreateCallback(feature) {            
    console.log("Feature created:", feature);
}

options.onRender = featureRenderCallback;
options.onCreate = featureCreateCallback;

Supported Versions

MapLibre GL JS 2.4 and later versions should be supported. Earlier versions probably won't work (not even tested anymore).


Contributing

Any contributions to this project are more than welcome. Feel free to reach us and we will gladly include any improvements or ideas that you may have. Please, fork this repository, make any changes and submit a Pull Request and we will get in touch!

Contributors

| Jorge Santos |:---:| | jdsantos | | github.com/jdsantos

Support

The easiest way to seek support is by submiting an issue on this repo.