leaflet tooltip word wrapping
for this question http://stackoverflow.com/q/41461929/3067143
by abubelinha
HTML
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css">
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<div id="map"></div>
CSS
.leaflet-tooltip{
maxWidth: 100px;
white-space: normal;
}
#map{
width: 500px;
height: 500px;
}
JavaScript
var tiles = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors, Points © 2012 LINZ'
}),
latlng = L.latLng(-37.82, 175.24);
var map = L.map('map', {center: latlng, zoom: 13, layers: [tiles]});
var marker = L.marker(latlng, { opacity: 0 }); //can be set to zero
marker.bindTooltip('im', { permanent: true, noWrap: true, className: "myTooltip", offset: [0, 0] });
marker.addTo(map);