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-grid-distance

v3.0.1

Published

A Leaflet plugin to show grid distances

Downloads

6

Readme

Copy# AxesLayerWithDistance npm version License: MIT

AxesLayerWithDistance is a custom Leaflet grid layer that displays a customizable grid with labeled axes on a Leaflet map. This library allows you to visualize distance scales directly on your map tiles, enhancing the map's usability and interactivity for educational, scientific, or navigational purposes.

Features

  • Customizable Grid: Configure the number of cells, color, and size of grid lines.
  • Axes Labels: Show distance labels on the axes in meters or kilometers.
  • Dynamic Centering: Set and update the center of the grid dynamically.
  • Snap Axes to Grid: Option to snap the axes to the nearest grid line.
  • Canvas Rendering: Utilizes HTML5 Canvas for efficient rendering.

Demo

Running Demo Link: Demo

Demo Screenshot

Installation

Install the package via npm:

npm install leaflet-grid-distance

Usage

First, import the library and Leaflet into your project:

import * as L from 'leaflet';
import { AxesLayerWithDistance, AxesLayerOptions } from 'axes-layer-with-distance';

Create a Map and Add the Layer

Here is a simple example of how to create a Leaflet map and add the AxesLayerWithDistance:

// Create a map
const map = L.map('map').setView([51.505, -0.09], 13);

// Add a tile layer (e.g., OpenStreetMap)
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  maxZoom: 19,
}).addTo(map);

// Create an AxesLayerWithDistance with options
const axesLayerWithDistance = AxesLayerWithDistance({
  primaryColor: '#ff0000',
  secondaryColor: '#999999',
  textColor: '#000000',
  fontSize: 12,
  kmThreshold: 13,
});

// Add the AxesLayerWithDistance to the map
axesLayerWithDistance.addTo(map);

Options

You can customize the AxesLayerWithDistance using the following options:

  • primaryColor: Color of the main axes lines. Default is '#ff0000'.
  • secondaryColor: Color of the grid lines. Default is '#999999'.
  • textColor: Color of the text labels. Default is '#000000'.
  • fontSize: Font size of the text labels. Default is 12.
  • kmThreshold: Zoom level threshold for switching between km and m units. Default is 13.
  • origin: Set the origin point of the grid layer.
  • snapAxesToGrid: Snap the axes to the nearest grid line. Default is false.

Methods

  • The AxesLayerWithDistance extends Leaflet's GridLayer and inherits all its methods.
  • changeOptions(options: Partial<AxesLayerOptions>): Update the options of the AxesLayerWithDistance and redraw the layer.

Contributing

We welcome contributions to improve this library. Please fork the repository, create a branch, and submit a pull request with your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Questions and Support

For any questions or support requests, please open an issue on the GitHub repository or contact me directly at [email protected].