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

alt-route-labeller

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alt-route-labeller

A library to compute the best position to put labels on multiple routes between two points

  • 0.3.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

alt-route-labeller

A library to compute the best position to put labels on multiple routes between two points.

Example use-cases

  • Showcase page.
  • In-depth explanation as a blog article.

Installation

Depending on your package manager:

npm install --save alt-route-labeller

or

yarn add alt-route-labeller

Usage

The lib exposes the getLabelPositions function.

Parameters

  • routes: the multiple routes to apply the labelling to. Can be expressed as a GeoJSON FeatureCollection, an array of Feature objects, or an array of Geometry objects.

Return value

An array of label positions, one for each of the routes, in the same order as they where passed to the function.

Each label position has the following properties:

  • lngLat: the best position of the label on the route, put on a non-ambiguous section not shared with other routes (if one can be found, otherwise fallback on the route middle position).
  • anchor: a hint value to minimize collisions if we want to display labels. Possible values: top|bottom|left|right. Inspired by the anchor property of MapBox-GL-JS markers.

Example

import { getLabelPositions } from 'alt-route-labeller';

const routes = getGeoJSONRoutesFromSomewhere();
const labels = getLabelPositions(routes);
labels.forEach(label => {
  createMarkerOnMap(label.lngLat, { anchor: label.anchor });
});

Keywords

FAQs

Package last updated on 21 Oct 2021

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