smart linebreaks in labels
This commit is contained in:
parent
4592132b3b
commit
075f3f7f08
2 changed files with 18 additions and 4 deletions
|
@ -579,12 +579,16 @@ main.show-options #resultswrapper #route-options {
|
|||
white-space: nowrap;
|
||||
}
|
||||
.location-label-text {
|
||||
background-color: rgba(255, 255, 255, 0.6);
|
||||
line-height: 100%;
|
||||
padding: 2px 3px;
|
||||
line-height: 110%;
|
||||
border-radius: 2px;
|
||||
white-space: nowrap;
|
||||
transform: translateX(-50%) translateY(-50%);
|
||||
text-align: center;
|
||||
|
||||
span {
|
||||
line-height: 110%;
|
||||
background-color: rgba(255, 255, 255, 0.6);
|
||||
}
|
||||
}
|
||||
|
||||
.locationinput {
|
||||
|
|
|
@ -823,7 +823,17 @@ c3nav = {
|
|||
return html[0].outerHTML;
|
||||
},
|
||||
_build_location_label: function(location) {
|
||||
var html = $('<div class="location-label-text">').text(location.label_override || location.title);
|
||||
var text = location.label_override || location.title, new_text = [''], len=0;
|
||||
for (segment of text.split(' ')) {
|
||||
if (len === 0 || len+segment.length < 12) {
|
||||
new_text[new_text.length-1] = (len?' ':'')+$('<div>').text(segment).html();
|
||||
len += segment.length;
|
||||
} else {
|
||||
new_text.push(segment);
|
||||
len = segment.length;
|
||||
}
|
||||
}
|
||||
var html = $('<div class="location-label-text">').append($('<span>').html((' '+new_text.join(' <br> ')+' ').replace(/ /g, ' ')));
|
||||
html.css('font-size', location.label_settings.font_size+'px');
|
||||
return L.marker(L.GeoJSON.coordsToLatLng(location.point.slice(1)), {
|
||||
icon: L.divIcon({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue