I have developed a map at https://afterfibre.nsrc.org/af_dev.html which should display a custom attribution in the lower right corner:

 L.tileLayer('https://dnv9my2eseobd.cloudfront.net/v3/cartodb.map-4xtxp73f/{z}/{x}/{y}.png', {
    attribution: 'Undersea cable data courtesy <a href="http://cablemap.info">Greg Malknecht</a><br>Mapbox <a href="http://mapbox.com/about/maps" target="_blank">Terms &amp; Feedback</a>'

and should have a custom legend:

      var aftLegend = new cdb.geo.ui.Legend.Custom({
        title: "Fibre Status",
        data: [
          { name: "Live",               value: "#58A062" },
          { name: "Under Construction", value: "#F07971" }

but no legend appears and the attribution remains the default. The map seems to work well in every other respect. No javascript errors detected. The full code is at


I have been through it several times but am at a loss to work out what I am doing wrong.

2 Answers 2


For the legend: map_object is a javascript object rather than a DOM element with an id. Just add a new element to your page like <div id="map_legend"></div> and append to that or append to the $("body") and it seems to work.

I was able to get attribution working if I created a control, but only if it was in the top right. L.control.attribution({position: 'topright', prefix: ''}).addTo(map_object);

Nice map!

  • Thank you!!! Both worked and top right is fine for now while the attribution issue is being sorted out.
    – SteveSong
    Sep 16, 2015 at 13:17

The attribution issue you're mentioning seems caused by some issue in our end in CartoDB.js 3.15. We're working right now in attributions management, and it seems that some of our changes are overwriting Leaflet attributions.

I'm going to report this to the team for they to take a look at it, but the attribution that you specify in Leaflet will be respected if you use CartoDB.js 3.15.3 or smaller (3.14).

Also, @thdak is right about the map_object, but you can use:


that will generate the legend inside your existent map container.

Edit: Actually, the attributions issue is going to be handled as an extension to this already existent issue https://github.com/CartoDB/cartodb.js/issues/681

  • Just want to say thanks for fixing the attribution issue as well. Works fine now. Much appreciated!
    – SteveSong
    Sep 17, 2015 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.