public/build/static/application.js
function addLegend(layer, data, options) {
    data = data || {};
    if ( !this.options.fills ) {
      return;
    }

    var html = '<dl>';
    var label = '';
    if ( data.legendTitle ) {
      html = '<h2>' + data.legendTitle + '</h2>' + html;
    }
    for ( var fillKey in this.options.fills ) {

      if ( fillKey === 'defaultFill') {
        if (! data.defaultFillName ) {
          continue;
        }
        label = data.defaultFillName;
      } else {
        if (data.labels && data.labels[fillKey]) {
          label = data.labels[fillKey];
        } else {
          label= fillKey + ': ';
        }
      }
      html += '<dt>' + label + '</dt>';
      html += '<dd style="background-color:' +  this.options.fills[fillKey] + '">&nbsp;</dd>';
    }
    html += '</dl>';

    var hoverover = d3.select( this.options.element ).append('div')
      .attr('class', 'datamaps-legend')
      .html(html);
  }
function addLegend(layer, data, options) {
    data = data || {};
    if ( !this.options.fills ) {
      return;
    }

    var html = '<dl>';
    var label = '';
    if ( data.legendTitle ) {
      html = '<h2>' + data.legendTitle + '</h2>' + html;
    }
    for ( var fillKey in this.options.fills ) {

      if ( fillKey === 'defaultFill') {
        if (! data.defaultFillName ) {
          continue;
        }
        label = data.defaultFillName;
      } else {
        if (data.labels && data.labels[fillKey]) {
          label = data.labels[fillKey];
        } else {
          label= fillKey + ': ';
        }
      }
      html += '<dt>' + label + '</dt>';
      html += '<dd style="background-color:' +  this.options.fills[fillKey] + '">&nbsp;</dd>';
    }
    html += '</dl>';

    var hoverover = d3.select( this.options.element ).append('div')
      .attr('class', 'datamaps-legend')
      .html(html);
  }
function addLegend ( layer , data , options ) { data = data || { } ; if ( ! this . options . fills ) { return ; } var html = '<dl>' ; var label = '' ; if ( data . legendTitle ) { html = '<h2>' + data . legendTitle + '</h2>' + html ; } for ( var fillKey in this . options . fills ) { if ( fillKey === 'defaultFill' ) { if ( ! data . defaultFillName ) { continue ; } label = data . defaultFillName ; } else { if ( data . labels && data . labels [ fillKey ] ) { label = data . labels [ fillKey ] ; } else { label = fillKey + ': ' ; } } html += '<dt>' + label + '</dt>' ; html += '<dd style="background-color:' + this . options . fills [ fillKey ] + '">&nbsp;</dd>' ; } html += '</dl>' ; var hoverover = d3 . select ( this . options . element ) . append ( 'div' ) . attr ( 'class' , 'datamaps-legend' ) . html ( html ) ; }
plugin to add a simple map legend
plugin to add a simple map legend