传单颜色在 Choropleth 中显示为深蓝色

Leaflet Color appearing as dark blue in Choropleth

我根据人口使用传单制作了一个等值线。

Leaflet 中有没有 属性 假设 5 个地方的人口刚好是 10,那么根本不给它们上色?好像没有填充?

我也搞不懂为什么我设置成奶油色的时候还有深蓝色。

这是我的风格功能。 -999 表示指标不存在,这就是为什么我不想在这里填充。

function style(feature)
{
    return {
        fill: feature.properties.metric == -999 ? false :true,
        fillColor: getColor(feature.properties.metric),
        weight: 4,
        opacity: 1,
        color: feature.properties.metric == -999 ? '#e4e3db' :getColor(feature.properties.metric),
        dashArray: feature.properties.metric == -999 ? '' : '3',
        fillOpacity: feature.properties.metric == -999 ? 0 : 0.5
    };
}

您可以使用 fill: false 选项禁用多边形填充。

参考:http://leafletjs.com/reference.html#path-options

这是一个关于 Plunker 的工作示例,因此您可以验证 fill: false 是否有效,只需注释掉 fill 属性 行,您就会看到:示例:http://plnkr.co/edit/5Kn94H?p=preview

显示的蓝色是 Leafet 的多边形默认颜色。所以你看到蓝色的地方,一定意味着你的语句、featuredata 或 getColor 方法有问题。但很难说,因为您遗漏了数据样本、getColor 方法并且没有在 Fiddle/Plunker 或其他地方提供测试用例。