javascript - 图例与 map 上的颜色不对应。融合表

标签 javascript css google-fusion-tables

我正在使用融合表 API 来设计 map 样式。然而在图例中,一些国家(乌干达和莫桑比克)没有显示图例中显示的正确颜色。

Link to the map

下面是显示图例的代码

    <style type="text/css">
  #legend {
    background-color: #FFF;
    margin: 10px;
    padding: 5px;
    width: 150px;
  }

  #legend p {
    font-weight: bold;
    margin-top: 3px;
  }

  #legend div {
    clear: both;
  }

  .color {
    height: 12px;
    width: 12px;
    margin-right: 3px;
    float: left;
    display: block;
  }
    #map-canvas{

        width: 700px;
        height: 650px;

    }
</style>

显示 map 的代码

function initialize() {
    var map = new google.maps.Map(document.getElementById('map-canvas'), {
      center: new google.maps.LatLng(-2.358937, 27.618881),
      zoom: 4,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var layer = new google.maps.FusionTablesLayer({
      query: {
        select: 'geometry',
        from: '1MXudMo9A8yUjpO89hkac74LzGEKPyA_tDzkWJ3hl'
      }
    });
    layer.setMap(map);

    initSelectmenu();
    for (column in COLUMN_STYLES) {
      break;
    }
    applyStyle(map, layer, column);
    addLegend(map);

    google.maps.event.addDomListener(document.getElementById('selector'),
        'change', function() {
          var selectedColumn = this.value;
          applyStyle(map, layer, selectedColumn);
          updateLegend(selectedColumn);
    });
  }

最佳答案

专栏'Total No of Points'已设置为类型 Text ,比较将基于不会给出预期结果的字符串。

简单测试:

alert('9'>'10');//true
alert(9>10);//false

解决方案:将列的类型设置为Number

关于javascript - 图例与 map 上的颜色不对应。融合表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24735032/

相关文章:

javascript - 显示从融合表到谷歌网站的特定名片

javascript - 国家的 Json - 使用哪种格式?

javascript - 从组件中的 useState 多次调用状态更新程序会导致多次重新渲染

javascript - beforeunload on IE 11 - 不提示用户不起作用

javascript - &lt;script for=foo event=onmouseover> 中的属性有什么作用

javascript - 如何根据下拉选择隐藏和显示内容

javascript - 使用复选框在 Google Fusion Tables 中进行过滤

javascript - document.execCommand ('copy' ) 在 React 中不起作用

html - div 宽度不会在调整大小时更新

CSS:双重声明有什么作用?