Skip to content

Instantly share code, notes, and snippets.

@calvinmetcalf
Last active December 15, 2015 09:29
Show Gist options
  • Save calvinmetcalf/5238965 to your computer and use it in GitHub Desktop.
Save calvinmetcalf/5238965 to your computer and use it in GitHub Desktop.
Use leaflet with bootstrap without the layer control looking horrible.
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