问题描述
我正在使用folium在pyqt5中编写应用程序以标记某些区域并获取gps坐标。应用程序正常运行,我可以绘制多边形,但是当我单击“导出”按钮时,没有任何反应。也许有人有类似的问题,知道为什么吗?
import folium,io,sys
from folium.plugins.draw import Draw
from PyQt5.QtWidgets import QApplication,QWidget,QVBoxLayout
from PyQt5 import QtWebEngineWidgets
class Mapy(QWidget):
def __init__(self,parent=None):
super().__init__(parent)
self.interfejs()
def interfejs(self):
vBox = QVBoxLayout(self)
self.webEngineView = QtWebEngineWidgets.QWebEngineView()
self.loadPage()
vBox.addWidget(self.webEngineView)
self.setLayout(vBox)
self.setGeometry(300,300,350,250)
self.setwindowTitle('mapy')
self.show()
def loadPage(self):
m = folium.Map(
location=[51.7687323,19.4569911],zoom_start=5
)
Draw(
export=True,filename='my_data.geojson',position='topleft',draw_options={'polyline': False,'rectangle': False,'circle':False,'circlemarker':False},edit_options={'poly': {'allowIntersection': False}}
).add_to(m)
data = io.BytesIO()
m.save(data,close_file=False)
self.webEngineView.setHtml(data.getvalue().decode())
if __name__ == '__main__':
app = QApplication(sys.argv)
okno = Mapy()
sys.exit(app.exec_())
解决方法
您必须使用页面配置文件中的downloadRequested
信号来管理下载:
df_grouped = df.groupby('name').agg(F.collect_list('value').alias('values'))