Skip to content
This repository has been archived by the owner on Mar 28, 2022. It is now read-only.

Adding option to display text only without background or border #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion dist/leaflet.label-src.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ L.Label = (L.Layer ? L.Layer : L.Class).extend({
noHide: false,
offset: [12, -15], // 6 (width of the label triangle) + 6 (padding)
opacity: 1,
zoomAnimation: true
zoomAnimation: true,
textOnly: false
},

initialize: function (options, source) {
Expand Down Expand Up @@ -130,6 +131,7 @@ L.Label = (L.Layer ? L.Layer : L.Class).extend({

_initLayout: function () {
this._container = L.DomUtil.create('div', 'leaflet-label ' + this.options.className + ' leaflet-zoom-animated');
if (this.options.textOnly) { L.DomUtil.addClass(this._container, 'leaflet-label-text-only'); }
this.updateZIndex(this._zIndex);
},

Expand Down
15 changes: 15 additions & 0 deletions dist/leaflet.label.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,18 @@
.leaflet-label-left:after {
content: "";
}

.leaflet-label.leaflet-label-text-only,
.leaflet-label.leaflet-label-text-only:before,
.leaflet-label.leaflet-label-text-only:after {
background: none;
border: none;
}

.leaflet-label.leaflet-label-text-only.leaflet-label-left {
margin-right: -10px;
}

.leaflet-label.leaflet-label-text-only.leaflet-label-right {
margin-left: -10px;
}
2 changes: 1 addition & 1 deletion dist/leaflet.label.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ L.Label = (L.Layer ? L.Layer : L.Class).extend({
noHide: false,
offset: [12, -15], // 6 (width of the label triangle) + 6 (padding)
opacity: 1,
zoomAnimation: true
zoomAnimation: true,
textOnly: false
},

initialize: function (options, source) {
Expand Down Expand Up @@ -115,6 +116,7 @@ L.Label = (L.Layer ? L.Layer : L.Class).extend({

_initLayout: function () {
this._container = L.DomUtil.create('div', 'leaflet-label ' + this.options.className + ' leaflet-zoom-animated');
if (this.options.textOnly) { L.DomUtil.addClass(this._container, 'leaflet-label-text-only'); }
this.updateZIndex(this._zIndex);
},

Expand Down