Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

leaflet-grid-distance

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-grid-distance

A Leaflet plugin to show grid distances

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
0
Weekly downloads
 
Created
Source

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

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 techyared.main@gmail.com.

Keywords

FAQs

Package last updated on 08 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc