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;

            cartodb.createLayer(currentMap, mapUrl)

            .on('done', function(layer) {       
                //do stuff

                .on('featureOver', function(e, latlng, pos, data) {
                    console.log(e, latlng, pos, data);

            .on('error', function(err) {
                alert("some error occurred: " + err);
        } <!--end function-->
        else {

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.