地图未显示与folium.Map()v0.10.0

问题描述 投票:0回答:1

Choropleth正在显示,但背景图只是灰色。在Jupyter中使用叶面0.10.0

显然曾经有一个_build_map()函数来执行此操作,该函数已从folium和folium.Map()中删除,但现在对某些人有效,但就我而言,这不是。我也尝试了.display(Map),但没有任何结果。

SF_map = folium.Map(location=SF_coordinates, tiles='Mapbox Bright', zoom_start=12)

display(SF_map)

folium.Choropleth(
    geo_data=SF_geo,
    name='Choropleth',
    data=df_incidents,
    columns=['Neighborhood', 'Count'],
    key_on='properties.DISTRICT',
    fill_color='YlOrRd',
    fill_opacity=0.7,
    line_opacity=0.2,
    legend_name='Crime Incidents by Neighborhood'    
).add_to(SF_map)

folium.LayerControl().add_to(SF_map)

SF_map

我希望可见地图的顶部有一个胆管层,但是它的胆管层是灰色的。当在添加圆度之前单独调用地图时,+和-缩放按钮会出现,并且一旦您达到缩放的极限,似乎就会起作用,但是它全是灰色的。没有错误消息返回。

python jupyter-notebook folium choropleth
1个回答
0
投票

[最有可能的地图没有出现(显示为灰色),因为无法加载图块,在这种情况下,控制台中显示以下错误:

enter image description here

即使在大叶中Mapbox Brightlisted among default tilesets

- "OpenStreetMap"
- "Mapbox Bright" (Limited levels of zoom for free tiles)
- "Mapbox Control Room" (Limited levels of zoom for free tiles)
- "Stamen" (Terrain, Toner, and Watercolor)
- "Cloudmade" (Must pass API key)
- "Mapbox" (Must pass API key)
- "CartoDB" (positron and dark_matter)

[Mapbox Bright磁贴集不再可用(类似的问题has been reported here

[切换到OpenStreetMap图块时:

coordinates = [37.7577627,-122.4726194]
map = folium.Map(location=coordinates, tiles='OpenStreetMap',  zoom_start=12)

folium.Choropleth(
    geo_data='https://cocl.us/sanfran_geojson' ,
    name='choropleth',
    data=df_incidents,
    columns = ['PdDistrict','IncidntNum'],
    key_on='feature.properties.DISTRICT',
    fill_color='YlOrRd',
    fill_opacity=0.6,
    line_opacity=0.2,
    legend_name='Crime in San Francisco'
).add_to(map)

map

箭头图层和地图正在按预期显示:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.