简体   繁体   中英

How to use folium map in PyQt5 offline

As the question state above. I would like to use an offline map that can work with PyQt5.(didnt need to be folium. I just like it's display )

Problem : is I every time the program start the map didn't load

I dont really know why. its work when I run the folium program alone. but when i use it with other stuff the map kinda just turn gray

在此处输入图像描述

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.

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

Link to preview for folium

Just a case of testing the tile servers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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