2

我正在使用基于 json 文件创建的folium地图。我使用branca.colormap添加了一个颜色图,并且我想添加一个背景颜色,因为生成的颜色图可能有一些颜色和它后面的地图,这会导致可视化问题。

我可以将此颜色图添加到框架中还是仅添加背景颜色?

4

1 回答 1

3

这是一个相当老套的解决方案,但它有效:

通过函数 . 打开由 folium 生成的 html 文件map_instance.save('map.html')

通过搜索查找生成传单控件的行.append("svg")

在其后插入此代码片段,确保变量名称正确(即从代码中的变量复制随机生成的 id)

color_map_<random_generated_id>.svg.append("rect")
    .attr("width", "100%")
    .attr("height", "100%")
    .attr("fill", "white")
    .attr("opacity", "0.8");

您还可以通过更改color_map_<random_generated_id>.legend变量中的传单控制位置属性来定位图例。在我的示例中,我使用L.control({position: 'bottomleft'});

图片示例

于 2018-05-19T15:50:52.647 回答