Last active
December 15, 2015 09:29
-
-
Save calvinmetcalf/5238965 to your computer and use it in GitHub Desktop.
Use leaflet with bootstrap without the layer control looking horrible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
L.Control.Layers.prototype._addItem= function (obj) { | |
var label = document.createElement('label'), | |
input, | |
checked = this._map.hasLayer(obj.layer); | |
if (obj.overlay) { | |
input = document.createElement('input'); | |
input.type = 'checkbox'; | |
input.className = 'leaflet-control-layers-selector'; | |
input.defaultChecked = checked; | |
} else { | |
input = this._createRadioElement('leaflet-base-layers', checked); | |
} | |
input.layerId = L.stamp(obj.layer); | |
L.DomEvent.on(input, 'click', this._onInputClick, this); | |
var name = document.createElement('span'); | |
name.innerHTML = ' ' + obj.name; | |
label.appendChild(input); | |
label.appendChild(name); | |
label.className = obj.overlay ? "checkbox" : "radio"; | |
var container = obj.overlay ? this._overlaysList : this._baseLayersList; | |
container.appendChild(label); | |
return label; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment