简体   繁体   中英

Cannot create a map using folium

The code I run:

import folium
map = folium.Map(location=[38.58, -99.09],
                 zoom_start=6,
                 tiles="Mapbox Bright")
map.save("Map1.html")

I saved it as map1.py and ran it with Visual Studio Code The error I get:

    Traceback (most recent call last):
    File "d:/development/Python/Python/35-web-app/map1.py", line 2, in <module>
        map = folium.Map(location=[38.58, -99.09], zoom_start=6, tiles="Mapbox Bright")
      File "C:\Users\hirusha\AppData\Local\Programs\Python\Python38\lib\site-packages\folium\folium.py", line 288, in __init__
        tile_layer = TileLayer(tiles=tiles, attr=attr,
      File "C:\Users\hirusha\AppData\Local\Programs\Python\Python38\lib\site-packages\folium\raster_layers.py", line 95, in __init__
        raise ValueError(
    ValueError: Built-in templates for Mapbox and Cloudmade have been removed. You can still use these providers by passing a URL to the `tiles` argument. See the documentation of the `TileLayer` class.

What can I go? Does it have to do something with my code? why isn't this working?

You can't use tiles="Mapbox Bright" anymore since built-in templates for Mapbox and Cloudmade have been removed.

Here is the documentation https://python-visualization.github.io/folium/modules.html Ctrl+F and look for class folium.raster_layers.TileLayer for further information

Find similar discussion at https://gis.stackexchange.com/questions/203062/using-mapbox-tiles-with-folium

Replace "Mapbox Bright" by "Stamen Terrain"

According to the documentation of the TileLayer class, replacing tiles="Mapbox Bright" by tiles="Stamen Terrain" works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM