# react-leaflet-textpath

> React wrapper of leaflet-textpath

Latest version **2.1.1** (published 2021-10-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-leaflet-textpath
pnpm add react-leaflet-textpath
yarn add react-leaflet-textpath
bun add react-leaflet-textpath
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2021-10-15 |
| First published | 2019-01-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 27.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Clement Allen |
| Maintainers | clementallen |
| Keywords | react, leaflet, react-leaflet, react-leaflet-v3, leaflet-textpath, react-leaflet-textpath |

## Links

- npm: https://www.npmjs.com/package/react-leaflet-textpath
- Repository: https://github.com/clementallen/react-leaflet-textpath
- Homepage: https://github.com/clementallen/react-leaflet-textpath#readme
- Issues: https://github.com/clementallen/react-leaflet-textpath/issues
- npm.io page: https://npm.io/package/react-leaflet-textpath

## Dependencies (1)

- [leaflet-textpath](https://npm.io/package/leaflet-textpath.md) ^1.2.3

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2021-10-15
- 2.0.0-0 (next) — 2021-01-21
- 2.1.0 — 2021-06-21
- 2.0.0 — 2021-01-24
- 1.0.9 — 2020-12-27
- 1.0.8 — 2020-05-19
- 1.0.7 — 2019-12-19
- 1.0.6 — 2019-05-12
- 1.0.5 — 2019-03-31
- 1.0.4 — 2019-03-10
- 1.0.3 — 2019-02-19
- 1.0.2 — 2019-02-04
- 1.0.1 — 2019-01-20
- 1.0.0 — 2019-01-15
- 0.1.0 — 2019-01-13

## README

# react-leaflet-textpath

[![](https://img.shields.io/npm/v/react-leaflet-textpath.svg?style=flat-square)](http://npmjs.com/package/react-leaflet-textpath)
[![](https://img.shields.io/npm/dt/react-leaflet-textpath.svg?style=flat-square)](http://npmjs.com/package/react-leaflet-textpath)
[![](https://img.shields.io/github/license/clementallen/react-leaflet-textpath.svg?style=flat-square)](https://github.com/clementallen/react-leaflet-textpath)
[![](https://img.shields.io/david/clementallen/react-leaflet-textpath.svg?style=flat-square)](https://david-dm.org/clementallen/react-leaflet-textpath)
[![](https://img.shields.io/david/dev/clementallen/react-leaflet-textpath.svg?style=flat-square)](https://david-dm.org/clementallen/react-leaflet-textpath?type=dev)
[![](https://img.shields.io/codeclimate/coverage/clementallen/react-leaflet-textpath.svg?style=flat-square)](https://codeclimate.com/github/clementallen/react-leaflet-textpath)
[![](https://img.shields.io/codeclimate/maintainability/clementallen/react-leaflet-textpath.svg?style=flat-square)](https://codeclimate.com/github/clementallen/react-leaflet-textpath)

React wrapper of [leaflet-textpath](https://github.com/makinacorpus/Leaflet.TextPath)
for [react-leaflet](https://github.com/PaulLeCam/react-leaflet).

Polyline with text for [Leaflet](https://leafletjs.com) maps. Extends [L.Polyline](http://leafletjs.com/reference.html#polyline).

_Most recently tested with Leaflet 1.7.1 and React-Leaflet 3.0.5_

## Requirements

The current version of this library supports React Leaflet v3. <br/>
If you are using React Leaflet v2, please use the v1 version of this library: <br/>
https://github.com/clementallen/react-leaflet-textpath/tree/v1

## Installation

```bash
npm install react-leaflet-textpath --save
```

## Usage

### Complete example with react-leaflet

```jsx
import { MapContainer, TileLayer } from 'react-leaflet';
import TextPath from 'react-leaflet-textpath';

<MapContainer center={[51.505, -0.09]} zoom={13}>
    <TileLayer
        url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
        attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
    />
    <TextPath
        positions={[
            [51.505, -0.09],
            [51.505, -0.02],
        ]}
        text="Polyline text"
        center
        offset={10}
    />
</MapContainer>;
```

### \<TextPath />

```jsx
<TextPath
    positions={[51.505, -0.09], [51.505, -0.02]}
    text="Polyline text"
    repeat
    center
    below
    offset={10}
    orientation={20}
    attributes={{
        'font-size': 20,
    }}
/>
```

#### Props

| Name        | Type                                               | Default      | Description                                                                                                                                   |
| ----------- | -------------------------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| positions   | Array of L.LatLng[] **or** Array\[number, number\] | **required** | Array of Latitude and Longitude points                                                                                                        |
| text        | string                                             | **required** | Text to display along the polyline                                                                                                            |
| repeat      | boolean                                            | false        | Repeat text along the polyline                                                                                                                |
| center      | boolean                                            | false        | Center text according to the polyline bounding box                                                                                            |
| below       | boolean                                            | false        | Show text underneath the polyline                                                                                                             |
| offset      | number                                             | 0            | Offset the text relative to the polyline                                                                                                      |
| orientation | number **or** string                               | 0            | Rotate text in degrees relative to the polyline                                                                                               |
| attributes  | object                                             | {}           | Attributes applied to the `text` tag. Check valid attributes [here](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/text#Attributes) |

**All other options from L.Polyline are also supported. [View them here](https://leafletjs.com/reference#polyline)**

---
_Source: https://npm.io/package/react-leaflet-textpath · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
