Reputation: 1
In the following codes:
import sys
import io
import folium
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout
from PyQt5.QtWebEngineWidgets import QWebEngineView
import geemap
class my_app(QWidget):
def __init__(self):
super(my_app, self).__init__()
self.setWindowTitle('GRSGA')
layout = QVBoxLayout()
self.setLayout(layout)
cordinate = (32.3265, 52.65241)
map = folium.Map(title='geors', zoom_start=8, location=cordinate)
data = io.BytesIO()
map.save(data, close_file=False)
web_view = QWebEngineView()
web_view.setHtml(data.getvalue().decode())
layout.addWidget(web_view)
if __name__ == "__main__":
app = QApplication(sys.argv)
app.setStyleSheet('''
QWidget{
font-size: 35px
}
''')
myapp = my_app()
myapp.show()
try:
sys.exit(app.exec_())
except SystemExit:
print('closing window')
i can display folium map in pyqt. but i want to use geemap instead of folium like the following code:
cordinate = (32.3265, 52.65241)
map = geemap.Map(title='geors', zoom_start=8, location=cordinate)
data = io.BytesIO()
map.save(data, close_file=False)
web_view = QWebEngineView()
web_view.setHtml(data.getvalue().decode())
layout.addWidget(web_view)
this codes return the following error:
Traceback (most recent call last):
File "D:\earth engine\gee_app\train1.py", line 28, in <module>
myapp = my_app()
File "D:\earth engine\gee_app\train1.py", line 17, in __init__
map.save(data, close_file=False)
File "D:\earth engine\gee_app\venv\lib\site-packages\ipyleaflet\leaflet.py", line 2220, in save
embed_minimal_html(outfile, views=[self], **kwargs)
File "D:\earth engine\gee_app\venv\lib\site-packages\ipywidgets\embed.py", line 302, in embed_minimal_html
snippet = embed_snippet(views, **kwargs)
TypeError: embed_snippet() got an unexpected keyword argument 'close_file'
how can i solve it?
Upvotes: 0
Views: 424
Reputation: 244252
The save()
method of geemap.Map()
does not accept the close_file
, also the fp must allow to write string instead of bytes, therefore io.StringIO()
must be used.
class my_app(QWidget):
def __init__(self):
super(my_app, self).__init__()
self.setWindowTitle("GRSGA")
layout = QVBoxLayout(self)
web_view = QWebEngineView()
layout.addWidget(web_view)
cordinate = (32.3265, 52.65241)
map = geemap.Map(title="geors", zoom_start=8, location=cordinate)
data = io.StringIO()
map.save(data)
web_view.setHtml(data.getvalue())
Upvotes: 0