Socket
Socket
Sign inDemoInstall

@geoblocks/elevation-profile

Package Overview
Dependencies
20
Maintainers
5
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @geoblocks/elevation-profile

A web component to display an elevation profile of a MultiLineString.


Version published
Maintainers
5
Created

Readme

Source

<elevation-profile>

A web component to display an elevation profile of a MultiLineString.

Installation

npm i --save @geoblocks/elevation-profile

Usage

 <elevation-profile .lines="${lines}"></elevation-profile>

API

Properties/Attributes

NameTypeDefaultDescription
linesnumber[][][]MultiLineString coordinates
pointsnumber[][]Points to be displayed on the profile
marginObject{top: 20, right: 20, bottom: 20, left: 40}Margin in pixels around the elevation profile
pointerEventsBooleantrueWhether to emit pointer events
tickSizeObject{x: 100, y: 40}Size of the ticks in pixels
localestringnavigator.languageLocale for the axis labels
tolerancenumber1Tolerance for the line simplification. Set to 0 to disable simplification

Ticks formating

The value of the tick in the axis can be changed by overriding the tickFormat method.

profile.tickFormat = (value, axis) => {
  return Math.round(value);
};

Where value is the value of the tick and axis is the axis where the tick is located (x or y).

Tick values

Ticks can be set manually using the tickValues method, passing an array of values and the desired axis (x of y). If values is null or the axis is not specified, ticks will be generated automatically.

profile.tickValues([100, 150, 200, 250], 'y');

Adding points

Points can be added to the profile by setting the points property. By default, the points will be displayed as circles on the profile. This can be changed by overriding the pointSvg method.

profile.pointSvg = (x, y, index) => {
  return `<circle cx="${x}" cy="${y}" r="5" fill="red" />`;
};

Where x and y are the position in pixels and index is the index of the point in the points array.

Events

If pointerEvents is true, the component will emit the following custom events on pointer interaction:

NameWhenDetail typeDescription
overThe pointer is over the profile{coordinate: number[], position: {x: number, y: number}}coordinate is the coordinate of the point on the MultiLineString and position is the position of the pointer relative to the component
outThe pointer leaves the profile

Styling

TODO: describe CSS selectors

FAQs

Last updated on 04 Mar 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc