I have a geojson layer named mapLayers and another geojson layer named lmiCounties, with a dropdown list with an item with the id lmiCounties. I want the second layer added to the first, which has already been added to the map when a user clicks on this item, and I want to do this with a function since I will have several layers/list items. The click capture is fine, its just that layer[0] (lmiCounties) does not associate with the actual lmiCounties geoJson layer. Seems like I am missing something simple here.
var lmiCounties = L.geoJson('some data');
document.getElementById('chooser').addEventListener("click", function(e) {
mapLayers.clearLayers();
layer = [e.target.id];
console.log(layer[0]);
mapLayers.addLayer(layer[0]);
e.preventDefault();
});