Custom icon for Leaflet with dynamic text
Custom icon for Leaflet with dynamic text
Adapted from: https://gist.github.com/comp615/2288108
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);
blue
(default), green
, red
blue
, green
, red
marker.options.icon.setColor('green');
marker.options.icon.setText('21');