python-visualization / folium

Python Data. Leaflet.js Maps.
https://python-visualization.github.io/folium/
MIT License
6.94k stars 2.23k forks source link

Map with grey spots or completely grey #1463

Closed gg-bt closed 2 years ago

gg-bt commented 3 years ago

Describe the bug It's been a week that I am not able to render anymore my map in my python application, before I was able to see with no issue at all. Now I see grey areas in the map when loaded or when the zoom is applied.

bug bug2

To Reproduce

import folium
import io
import sys
from PyQt5 import QtWidgets, QtWebEngineWidgets

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)

#view the dataset
    view = QtWebEngineWidgets.QWebEngineView()
    center = [-0.023559, 37.9061928]
    map_kenya = folium.Map(location=center, zoom_start=8)

# save map to html file
    data = io.BytesIO()
    map_kenya.save(data, close_file=False)
    view.setHtml(data.getvalue().decode())
    view.show()
    app.exec()

Expected behavior I would expect to be able to load the map with no issue, being able to zoom in and out without having big grey areas.

Environment (please complete the following information): This is basically a standalone map, not relying on any browser.

kkangy commented 3 years ago

I have same problem. The only way to operate the folium on the qtwebengine of pyqt5 that I have tested so far is to add tails="cartodb positron" option now.

MStillman commented 3 years ago

Had the same issue, it looks like the only maps working are the German openstreetmap and some of the others , Opentopomap and the cartodb positron, work as well but the .org maps dont. Not checked anymore

gg-bt commented 3 years ago

Guys, I am currently using the tile Stamen Terrain and works fine! Never tried again the default one...

pstatonwx commented 2 years ago

Super late answer, but to fix this, you may or may not need a MapBox API key.

Check out some examples how to put them in here: http://leaflet-extras.github.io/leaflet-providers/preview/

For example (no key needed):

folium.TileLayer(
            name="White Basemap",
            tiles="https://tiles.stadiamaps.com/tiles/alidade_smooth/{z}/{x}/{y}{r}.png",
            attr="'&copy; <a href='https://stadiamaps.com/'>Stadia Maps</a>, &copy; <a 
            href='https://openmaptiles.org/'>OpenMapTiles</a> &copy; <a href='http://openstreetmap.org'>OpenStreetMap</a> 
            contributors",
            detect_retina=True,
        ).add_to(<your folium map name here>)
Conengmo commented 2 years ago

Unfortunately this is very likely not something we can help with. Tile images are retrieved from an external server, in case of the OP from OpenStreetMap. If something goes wrong in that connection, you will get grey squares.

If somebody has more insight, please share it here.