2.1.1 • Published 3 years ago

react-leaflet-textpath v2.1.1

Weekly downloads
192
License
MIT
Repository
github
Last release
3 years ago

react-leaflet-textpath

npm.io npm.io npm.io npm.io npm.io npm.io npm.io

React wrapper of leaflet-textpath for react-leaflet.

Polyline with text for Leaflet maps. Extends L.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. If you are using React Leaflet v2, please use the v1 version of this library: https://github.com/clementallen/react-leaflet-textpath/tree/v1

Installation

npm install react-leaflet-textpath --save

Usage

Complete example with react-leaflet

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
    positions={[51.505, -0.09], [51.505, -0.02]}
    text="Polyline text"
    repeat
    center
    below
    offset={10}
    orientation={20}
    attributes={{
        'font-size': 20,
    }}
/>

Props

NameTypeDefaultDescription
positionsArray of L.LatLng[] or Array[number, number]requiredArray of Latitude and Longitude points
textstringrequiredText to display along the polyline
repeatbooleanfalseRepeat text along the polyline
centerbooleanfalseCenter text according to the polyline bounding box
belowbooleanfalseShow text underneath the polyline
offsetnumber0Offset the text relative to the polyline
orientationnumber or string0Rotate text in degrees relative to the polyline
attributesobject{}Attributes applied to the text tag. Check valid attributes here

All other options from L.Polyline are also supported. View them here

2.1.1

3 years ago

2.1.0

3 years ago

2.0.0

3 years ago

2.0.0-0

3 years ago

1.0.9

3 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.1.0

5 years ago