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

leaflet-qgsmeasure

v0.0.8

Published

Leaflet control to measure segment distances on the map like Qgis Ruler.

Downloads

495

Readme

Leaflet.QgsMeasure

Leaflet control to measure segment distances on the map like Qgis Ruler.

Requires Leaflet 1.0.0+ branches

Requires Leaflet.Draw

Install

npm install leaflet-qgsmeasure

Demo

Check out the demo

Usage

As map option:

const map = L.map('map', { measureControl: true });

Or like any control:

const options = {}; // See docs to see options
L.Control.qgsmeasure(options)
  .addTo(map);

Docs

Options:

// Default plugin options object, change wathever you want
options = {
  position: 'topleft',
  shapeOptions: {
    color: "#d07f03",
    stroke: true,
    weight: 4,
    opacity: 0.7,
  },
  icon: new L.DivIcon({
    iconSize: new L.Point(9, 9),
    className: 'leaflet-div-icon leaflet-editing-icon',
  }),
  text: {
    title: 'Measure distances', // Plugin Button Text
    segments_title: 'Segments (meters)', // Segments box title
    segments_from: "From ", // Segment start label
    segments_to: "to ", // Segment end label
    segments_total: 'Total: ', // Total distance label
    segments_meters: "m", // Meters label
  },
};

Methods

| Method Name | Description | |-------------|---------------------------------------------------| | enabled | Gets a true/false of whether the ruler is enabled | | getSegments | Returns a list with all segments in map | | toggle | Toggles the ruler on or off |

Events:

  • qgsmeasure:measurestart - Event fired when the measure handler are added to map
  • qgsmeasure:newsegment - Event fired when a new segment/vertex is added
    // Event data example: Event fired after inserting 2 -> 3 segment
    {
      segment: {
        from: 2,
        to: 3,
        distance: 420.2680458268559
      },
      segments: [ // List with every segment on map
        {
          from: 1,
          to: 2,
          distance: 729.5775168261067
        },
        {
          from: 2,
          to: 3,
          distance: 420.2680458268559
        },
      ],
      type: "qgsmeasure:newsegment",
    // target ...,
    // sourceTarget...,
    }
  • qgsmeasure:newmeasure - Event fired when the user starts a new measure
  • qgsmeasure:measurestop - Event fired when the measure handler are removed from map

Custom html button

If you are developing a web application and you want to use your own html button outside the map container, you can use the following code:

const options = {
  button: document.getElementById('my-button'), // Your html button HTML reference
}

const control = L.Control.qgsmeasure(options)
  .addTo(map);

After that, you have to make your own segments output box using the events described above.

You can see the example here

Development

npm install --save-dev     # install dependencies
npm run dev  # Compile and save at dist/ after any change

Open index.html in your browser and start editing.

Changelog

See CHANGELOG.md.

Authors

  • Gabriel Russo

Forked from (Credits)

  • Gilles Bassière
  • Alexandra Janin
  • Makina Corpus