makinacorpus/Leaflet.TextPath

Name: Leaflet.TextPath

Owner: Makina Corpus

Description: Show text along Polyline with Leaflet

Created: 2013-03-06 10:18:03.0

Updated: 2017-12-12 23:33:25.0

Pushed: 2017-11-23 18:01:56.0

Homepage: http://makinacorpus.github.com/Leaflet.TextPath/

Size: 296

Language: HTML

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Leaflet.TextPath

Shows a text along a Polyline.

Check out the demo !

Leaflet versions

The version on the gh-pages branch targets Leaflet 0.7.3.

Please use the leaflet0.8-dev branch to be compatible with the development version of Leaflet (0.8).

Usage

For example, show path orientation on mouse over :

var layer = L.polyLine(...);

layer.on('mouseover', function () {
    this.setText('  ?  ', {repeat: true, attributes: {fill: 'red'}});
});

layer.on('mouseout', function () {
    this.setText(null);
});

With a GeoJSON containing lines, it becomes:

L.geoJson(data, {
    onEachFeature: function (feature, layer) {
        layer.setText(feature.properties.label);
    }
}).addTo(map);
Options
Screenshot

screenshot

Credits

The main idea comes from Tom Mac Wright's Getting serious about SVG

Changelog
development
1.1.0
1.0.2
1.0.1
1.0.0

Breaking changes

0.2.2
0.2.1
0.2.0
0.1.0
Authors

Many thanks to all contributors !

Makina Corpus


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.