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

leaflet-grid-distance

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet-grid-distance - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0

dist/AxesGridLayer.bundle.js

2

dist/AxesGridLayer.d.ts

@@ -8,4 +8,6 @@ import * as L from 'leaflet';

kmThreshold: number;
origin?: L.LatLngExpression;
snapAxesToGrid?: boolean;
}
declare function AxesLayerWithDistance(opts: Partial<AxesLayerOptions>): L.GridLayer;
export { AxesLayerWithDistance, AxesLayerOptions };

23

dist/AxesGridLayer.js

@@ -36,2 +36,3 @@ "use strict";

kmThreshold: 13,
snapAxesToGrid: false
},

@@ -41,7 +42,12 @@ initialize: function (options) {

L.GridLayer.prototype.initialize.call(this, options);
this._center = null;
this._center = this.options.origin ? this.options.origin : null;
},
changeOptions(options) {
this.initialize(options);
this.redraw();
},
onAdd: function (map) {
L.GridLayer.prototype.onAdd.call(this, map);
this._center = map.getCenter();
this._center = this.options.origin ? this.options.origin : map.getCenter();
map.setView(this._center);
map.on('move', this._onMove, this);

@@ -55,3 +61,3 @@ },

_onMove: function (e) {
this._center = this._map.getCenter();
this._center = this.options.origin ? this.options.origin : this._map.getCenter();
this.redraw();

@@ -67,3 +73,3 @@ },

if (!this._center && this._map) {
this._center = this._map.getCenter();
this._center = this.options.origin ? this.options.origin : this._map.getCenter();
}

@@ -100,4 +106,6 @@ if (this._center) {

// Snap axes to nearest grid line
xAxisY = Math.round(xAxisY / gridSize) * gridSize;
yAxisX = Math.round(yAxisX / gridSize) * gridSize;
if (this.options.snapAxesToGrid) {
xAxisY = Math.round(xAxisY / gridSize) * gridSize;
yAxisX = Math.round(yAxisX / gridSize) * gridSize;
}
// Draw main axes

@@ -174,3 +182,4 @@ ctx.strokeStyle = this.options.primaryColor;

_getScale: function (zoom) {
const centerLatLng = this._center || this._map.getCenter();
const centerLatLng = this._center || this.options.origin ? this.options.origin : this._map.getCenter();
;
const pointC = this._map.project(centerLatLng, zoom);

@@ -177,0 +186,0 @@ const pointX = L.point(pointC.x + this.options.tileSize / 2, pointC.y);

{
"name": "leaflet-grid-distance",
"version": "2.0.1",
"version": "3.0.0",
"description": "A Leaflet plugin to show grid distances",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"test": "echo \"Error: no test specified\" && exit 1"
"build": "tsc && webpack",
"prepublishOnly": "npm run build"
},
"keywords": ["leaflet", "grid", "distance", "map"],
"keywords": [
"leaflet",
"grid",
"distance",
"map"
],
"author": "TechyAReD",

@@ -26,4 +35,7 @@ "license": "MIT",

"@types/leaflet": "^1.9.12",
"typescript": "^5.5.4"
"ts-loader": "^9.5.1",
"typescript": "^5.5.4",
"webpack": "^5.93.0",
"webpack-cli": "^5.1.4"
}
}

@@ -1,6 +0,4 @@

# AxesLayerWithDistance
Here's the updated README file:
Copy# AxesLayerWithDistance [![npm version](https://badge.fury.io/js/axes-layer-with-distance.svg)](https://badge.fury.io/js/axes-layer-with-distance) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![npm version](https://badge.fury.io/js/axes-layer-with-distance.svg)](https://badge.fury.io/js/axes-layer-with-distance)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/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.

@@ -13,2 +11,3 @@

- **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.

@@ -18,4 +17,6 @@

![Demo Screenshot](./src//screenshot/image.png)
### Running Demo Link: [Demo](https://aredtech.github.io/leaflet-grid-distance/)
![Demo Screenshot](./src/screenshot/image.png)
## Installation

@@ -74,5 +75,8 @@

- **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. There are no additional public methods specific to AxesLayerWithDistance.
- 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.

@@ -79,0 +83,0 @@ ## Contributing

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