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;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.location-label-text {
|
.location-label-text {
|
||||||
background-color: rgba(255, 255, 255, 0.6);
|
line-height: 110%;
|
||||||
line-height: 100%;
|
|
||||||
padding: 2px 3px;
|
|
||||||
border-radius: 2px;
|
border-radius: 2px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
transform: translateX(-50%) translateY(-50%);
|
transform: translateX(-50%) translateY(-50%);
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
span {
|
||||||
|
line-height: 110%;
|
||||||
|
background-color: rgba(255, 255, 255, 0.6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.locationinput {
|
.locationinput {
|
||||||
|
|
|
@ -823,7 +823,17 @@ c3nav = {
|
||||||
return html[0].outerHTML;
|
return html[0].outerHTML;
|
||||||
},
|
},
|
||||||
_build_location_label: function(location) {
|
_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');
|
html.css('font-size', location.label_settings.font_size+'px');
|
||||||
return L.marker(L.GeoJSON.coordsToLatLng(location.point.slice(1)), {
|
return L.marker(L.GeoJSON.coordsToLatLng(location.point.slice(1)), {
|
||||||
icon: L.divIcon({
|
icon: L.divIcon({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue