Closed veragreen119 closed 4 years ago
I was just pondering this and realized the + and - symbol is also not centered. See comparison screenshot. I'm using Leaflet 1.5.1 - but not related to that, same issue with 1.4/1.3. Issue is related to bootstrap library being present in my map. comparison_screenshot.zip
To adjust the alignments of icons you need to edit the style sheet mainly so that the minimum size is such that the icon is still in the button. I made a few changes to leaflet-panal-layers.css to fix this bellow yo8u can see an updated version with a few comments by what was changed. I couldn't get the vertical alignment of text to work properly as it seams to be in its own span. but it is in the right spot.
/* PANEL LAYERS */
.leaflet-panel-layers .leaflet-panel-layers-list {
display: block;
}
.leaflet-panel-layers.expanded .leaflet-panel-layers-list {
display: block;
}
.leaflet-top.leaflet-right .leaflet-panel-layers:not(.compact) {
margin: 0;
}
/*the width of the sidebar when collapsed*/
.leaflet-panel-layers {
width: 50px;
min-width: 50px;
}
.leaflet-panel-layers.expanded {
width: auto;
overflow-x: hidden;
overflow-y: auto;
}
.leaflet-panel-layers.expanded .leaflet-panel-layers-list {
display: block;
}
.leaflet-panel-layers:not(.expanded) .leaflet-panel-layers-title > span,
.leaflet-panel-layers:not(.expanded) .leaflet-panel-layers-selector,
.leaflet-panel-layers:not(.expanded) .leaflet-panel-layers-grouplabel {
display: none;
}
.leaflet-panel-layers-separator {
clear: both;
}
.leaflet-panel-layers-item .leaflet-panel-layers-title {
display: block;
white-space: nowrap;
float: none;
cursor: pointer;
}
.leaflet-panel-layers-title .leaflet-panel-layers-selector {
float: right;
}
.leaflet-panel-layers-group {
position: relative;
width: auto;
height: auto;
clear: both;
overflow: hidden;
}
.leaflet-panel-layers-icon {
text-align: center;
float: left;
}
/*These are the hights for group layers*/
.leaflet-panel-layers-group.collapsible:not(.expanded) {
height: 32px;
}
.leaflet-panel-layers-group.collapsible:not(.expanded) .leaflet-panel-layers-grouplabel {
height: 32px;
overflow: hidden;
}
.leaflet-panel-layers-group.collapsible:not(.expanded) .leaflet-panel-layers-item {
display: none;
}
.leaflet-panel-layers-group.collapsible .leaflet-panel-layers-icon:first-child {
cursor: pointer;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.leaflet-panel-layers-item {
display: block;
height: auto;
clear: both;
white-space: nowrap;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.leaflet-panel-layers-overlays .leaflet-panel-layers-item {
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word;
width: auto;
display: block;
}
.leaflet-panel-layers-base .leaflet-panel-layers-selector {
float: left;
}
.leaflet-panel-layers-overlays .leaflet-panel-layers-selector {
float: right;
}
.leaflet-panel-layers.expanded .leaflet-panel-layers-overlays input {
display: block;
}
.leaflet-control-layers-selector {
float: left;
}
/* theming style */
.leaflet-panel-layers {
padding: 4px;
background: rgba(255,255,255,0.5);
box-shadow: -2px 0 8px rgba(0,0,0,0.3);
}
.leaflet-panel-layers.expanded {
padding: 4px;
}
.leaflet-panel-layers-selector {
position: relative;
top: 1px;
margin-top: 2px;
}
.leaflet-panel-layers-separator {
height: 8px;
margin: 12px 4px 0 4px;
border-top:1px solid rgba(0,0,0,0.3);
}
.leaflet-panel-layers-item {
/*the height of colaped items*/
min-height: 32px;
}
.leaflet-panel-layers-margin {
height: 25px;
}
.leaflet-panel-layers-icon {
line-height: 20px;
display: inline-block;
height: 20px;
width: 20px;
padding: 3px;/*adding padding here makes the icons 32x32*/
background: #fff;
}
.leaflet-panel-layers-group.collapsible .leaflet-panel-layers-icon:first-child {
min-width: 20px;
font-size: 16px;
text-align: center;
background: none;
}
.leaflet-panel-layers-group {
padding: 2px 4px;
margin-bottom: 4px;
border: 1px solid rgba(0,0,0,0.3);
background: rgba(255,255,255,0.6);
border-radius: 3px;
}
.leaflet-panel-layers-overlays .leaflet-panel-layers-item {
margin-bottom: 4px;
padding: 2px;
background: #fff;
border: 1px solid rgba(0,0,0,0.3);
border-radius: 4px;
}
.leaflet-panel-layers-overlays .leaflet-panel-layers-item:hover {
border: 1px solid #888;
cursor: pointer;
}
This works. thanks.
To get a bit more space between the icon and the check box:
.leaflet-panel-layers-icon {
line-height: 20px;
display: inline-block;
height: 20px;
width: 20px;
padding: 3px;/*adding padding here makes the icons 32x32*/
background: #fff;
padding-right: 25px;/*adding padding here creates some space between the icon and the label*/
}
Still looking for a way to get a bit of space between the checkbox and the label.This might require adding a css class.
The issue was actually with bootstrap applying a global rule which effected the menus to fix it load the fallowing css after loading bootstrap this will override the offending css rules everywhere.
<style type="text/css" >
*{
-webkit-box-sizing: unset;
-moz-box-sizing: unset;
box-sizing: unset;
}
</style>
if they are needed for other bootstrap features the following rules seem to fix the issue for just this plugin
.leaflet-panel-layers-group {
-webkit-box-sizing: unset;
-moz-box-sizing: unset;
box-sizing: unset;
}
.leaflet-panel-layers-item {
-webkit-box-sizing: unset;
-moz-box-sizing: unset;
box-sizing: unset;
}
.leaflet-panel-layers{
-webkit-box-sizing: unset;
-moz-box-sizing: unset;
box-sizing: unset;
}
thankyou @syonfox
I am following the code in this example: https://labs.easyblog.it/maps/leaflet-panel-layers/examples/collapsible-panel.html
It is all working and I was also able to use a glyphicon instead of a saved icon. My issue is that I can not get the icons (either from file or glyphicon source) to center in the collapsed window. Any advice?
Relevant sections of code attached. I tested the CSS in JFiddle and it correctly places the icon at the center of the box so it must be that the box is not centered.
code.zip