简体   繁体   English

如何在 PyQt5 中离线使用叶 map

[英]How to use folium map in PyQt5 offline

As the question state above.正如上面的问题 state。 I would like to use an offline map that can work with PyQt5.(didnt need to be folium. I just like it's display )我想使用可以与 PyQt5 一起使用的离线 map。(不需要是叶。我只是喜欢它的显示)

Problem : is I every time the program start the map didn't load问题:是不是我每次程序启动 map 都没有加载

I dont really know why.我真的不知道为什么。 its work when I run the folium program alone.当我单独运行folium程序时它的工作。 but when i use it with other stuff the map kinda just turn gray但是当我将它与其他东西一起使用时,map 有点变灰

在此处输入图像描述

so is there any solution I can try?那么有什么我可以尝试的解决方案吗?

here is my code这是我的代码

def getmap(coordinate):
     m = folium.Map(
     tiles="Location",
     zoom_start=20,
     Location=coordinate
     ,attr='&copy;<ahref="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
      )
      print(m)
      data = io.BytesIO()
      m.save(data, close_file=False)
      return data

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        dt=getmap((13.726807, 100.527764))
        self.C_Map = QtWebEngineWidgets.QWebEngineView(self.tab_1)
        self.C_Map.setUrl(QtCore.QUrl("about:blank"))
        self.C_Map.setObjectName("C_Map")
        self.C_Map.setHtml(dt.getvalue().decode())
        self.gridLayout_6.addWidget(self.C_Map, 11, 14, 8, 6)

For anyone else who has this issue, openstreemap.org doesn't seem to work anymore.对于遇到此问题的其他人,openstreemap.org 似乎不再起作用。

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png')

doesn't work you can use the German maps as these I know work:不起作用你可以使用德国地图,因为我知道这些工作:

L.tileLayer('https://{s}.tile.openstreetmap.de/{z}/{x}/{y}.png')

not had any luck with the French, Czech, or the bzh maps they all turned out grey as well, some of the others work fine though对法国、捷克或 bzh 地图没有任何运气,它们也都是灰色的,但其他一些工作正常

Link to preview for folium folium 预览链接

Just a case of testing the tile servers.只是测试瓦片服务器的一个案例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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