Per my previous question - here - how do I get the legend to toggle (I have it turned off now) in conjunction with toggling the cartodb layer via the leaflet layer control? Maybe adding it as a variable some way?
var cdb_url = 'http://ovrdc.cartodb.com/api/v2/viz/52a89830-a8c1-11e4-b072-0e0c41326911/viz.json';
cartodb.createLayer(map, cdb_url, {legends:false})
.addTo(map)
.on('done', function(crashes) {
crashes.setZIndex(2);
var overlayMaps = {
"Vehicle Crashes": crashes
};
L.control.layers(baseMaps, overlayMaps, {collapsed: false}).addTo(map);
})
.on('error', function(err) {
alert("some error occurred: " + err);
});