Leaflet.TextIcon

TODO - rewrite to TypeScript

Leaflet.TextIcon

Custom icon for Leaflet with dynamic text

Adapted from: https://gist.github.com/comp615/2288108

Usage

Install with bower: bower install Leaflet.TextIcon

Link script and css into html (or use wiredep):

<link rel="stylesheet" href="bower_components/Leaflet.TextIcon/leaflet-text-icon.css" />
<script src="bower_components/Leaflet.TextIcon/leaflet-text-icon.js"></script>

Create marker with L.TextIcon:

var icon = new L.TextIcon({ text: '12', color: 'red' });
var marker = L.marker([lat, lng], { icon: icon }).addTo(map);

Options

Methods

marker.options.icon.setColor('green');
marker.options.icon.setText('21');

Demo