I am trying to remove the legend associated with the current CartoDB generated map and replace it with a legend from a map generated when the user selects a radio button. My code is as follows:
function showMap(radioButton, currentLayer, currentMap, mapUrl) { if (radioButton.checked == true) { if (currentMap.viz != null) { var vis = currentMap.viz; vis.legends.getLegendByIndex(0).remove(); } cartodb.createLayer(currentMap, mapUrl) .addTo(currentMap) .on('done', function(layer) { //do stuff currentLayer=layer .on('featureOver', function(e, latlng, pos, data) { console.log(e, latlng, pos, data); }) }) .on('error', function(err) { alert("some error occurred: " + err); }); } else { currentLayer.hide(); } } Any help would be greatly appreciated. Thanks.
أكثر...
function showMap(radioButton, currentLayer, currentMap, mapUrl) { if (radioButton.checked == true) { if (currentMap.viz != null) { var vis = currentMap.viz; vis.legends.getLegendByIndex(0).remove(); } cartodb.createLayer(currentMap, mapUrl) .addTo(currentMap) .on('done', function(layer) { //do stuff currentLayer=layer .on('featureOver', function(e, latlng, pos, data) { console.log(e, latlng, pos, data); }) }) .on('error', function(err) { alert("some error occurred: " + err); }); } else { currentLayer.hide(); } } Any help would be greatly appreciated. Thanks.
أكثر...