# @turf/point-on-line

> turf point-on-line module

Latest version **5.0.3** (published 2017-10-02) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @turf/point-on-line
pnpm add @turf/point-on-line
yarn add @turf/point-on-line
bun add @turf/point-on-line
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 5.0.3 |
| Published | 2017-10-02 |
| First published | 2016-07-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 7 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10479 |
| Author | Turf Authors |
| Maintainers | deniscarriere, tcql, morganherlocker, tmcw |

## Links

- npm: https://www.npmjs.com/package/@turf/point-on-line
- Repository: https://github.com/Turfjs/turf
- Issues: https://github.com/Turfjs/turf/issues
- npm.io page: https://npm.io/package/@turf/point-on-line

## Dependencies (7)

- [@turf/meta](https://npm.io/package/@turf/meta.md) 5.0.0
- [@turf/bearing](https://npm.io/package/@turf/bearing.md) 5.0.0
- [@turf/helpers](https://npm.io/package/@turf/helpers.md) 5.0.0
- [@turf/distance](https://npm.io/package/@turf/distance.md) 5.0.0
- [@turf/invariant](https://npm.io/package/@turf/invariant.md) 5.0.0
- [@turf/destination](https://npm.io/package/@turf/destination.md) 5.0.0
- [@turf/line-intersect](https://npm.io/package/@turf/line-intersect.md) ^5.0.3

## Recent versions

- 5.0.3 (latest) — 2017-10-02
- 4.7.1 (lerna-temp) — 2017-09-05
- 3.5.2-alpha.d2c36ee7 (canary) — 2016-11-04
- 5.0.2 — 2017-10-02
- 5.0.0 — 2017-10-02
- 4.7.3 — 2017-09-12
- 4.7.0 — 2017-09-05
- 4.6.0 — 2017-08-02
- 4.5.2 — 2017-06-30
- 4.5.1 — 2017-06-30
- 4.4.0 — 2017-06-06
- 4.3.0 — 2017-05-12
- 4.2.0 — 2017-04-30
- 4.1.0 — 2017-04-10
- 4.0.2 — 2017-04-06
- … 23 more at https://npm.io/package/@turf/point-on-line/versions

## README

# @turf/point-on-line

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

## pointOnLine

Takes a [Point](http://geojson.org/geojson-spec.html#point) and a [LineString](http://geojson.org/geojson-spec.html#linestring) and calculates the closest Point on the (Multi)LineString.

**Parameters**

-   `lines` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;([LineString](http://geojson.org/geojson-spec.html#linestring) \| [MultiLineString](http://geojson.org/geojson-spec.html#multilinestring))>)** lines to snap to
-   `pt` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** point to snap from
-   `units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** can be degrees, radians, miles, or kilometers (optional, default `kilometers`)

**Examples**

```javascript
var line = turf.lineString([
    [-77.031669, 38.878605],
    [-77.029609, 38.881946],
    [-77.020339, 38.884084],
    [-77.025661, 38.885821],
    [-77.021884, 38.889563],
    [-77.019824, 38.892368]
]);
var pt = turf.point([-77.037076, 38.884017]);

var snapped = turf.pointOnLine(line, pt, 'miles');

//addToMap
var addToMap = [line, pt, snapped];
snapped.properties['marker-color'] = '#00f';
```

Returns **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)>** closest point on the `line` to `point`. The properties object will contain three values: `index`: closest point was found on nth line part, `dist`: distance between pt and the closest point, `location`: distance along the line between start and the closest point.

<!-- This file is automatically generated. Please don't edit it directly:
if you find an error, edit the source file (likely index.js), and re-run
./scripts/generate-readmes in the turf project. -->

---

This module is part of the [Turfjs project](http://turfjs.org/), an open source
module collection dedicated to geographic algorithms. It is maintained in the
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
PRs and issues.

### Installation

Install this module individually:

```sh
$ npm install @turf/point-on-line
```

Or install the Turf module that includes it as a function:

```sh
$ npm install @turf/turf
```

---
_Source: https://npm.io/package/@turf/point-on-line · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
