I have PyQt5 app that embeds a folium Map within a QWidget.
Here's a minimal example of the class I wrote :
import folium
import io
from folium.plugins import Draw, MousePosition, HeatMap
from PySide2 import QtWidgets, QtWebEngineWidgets
class FoliumMap(QtWidgets.QWidget):
def __init__(self, parent=None):
QtWidgets.QWidget.__init__(self, parent)
self.layout = QtWidgets.QVBoxLayout()
m = folium.Map(
title='coastlines',
zoom_start=3)
data = io.BytesIO()
m.save(data, close_file=False)
webView = QtWebEngineWidgets.QWebEngineView()
webView.setHtml(data.getvalue().decode())
self.layout.addWidget(webView)
self.setLayout(self.layout)
If i run my program here's what I have :
Now I want to add a GeoJson layer within the __init__
of my class :
folium.GeoJson('data/custom.geo.json', name='coasts').add_to(m)
This results in having a blank Qwidget :
If I save the map under html format I am able to see the layer on my web browser:
Has anyone an idea on why the layer implementation makes the QWidget blank ? And how to fix this ?