<div dir="ltr"><div dir="ltr">I'm busy developing an app using the QGIS Python api,
PyQGIS, and am noticing some strange behaviour when loading WMS tiles:
Running the python script on Linux Mint loads xyz layers from Google
Maps and Google Satellite just fine. On Windows, only the Google Maps
layer loads. <br><br>Here is a test script I wrote to demonstrate the problem:<br><br><span style="font-family:monospace,monospace">from qgis.core import QgsApplication, QgsProject, QgsRasterLayer<br>from qgis.gui import QgsMapCanvas, QgsLayerTreeMapCanvasBridge<br></span></div><div dir="ltr"><span style="font-family:monospace,monospace"><br></span></div><div dir="ltr"><span style="font-family:monospace,monospace">from PyQt5.QtWidgets import QMainWindow<br>import os<br><br>GOOGLE_MAPS_SOURCE = "type=xyz&url=<a href="https://mt1.google.com/vt?lyrs%3Dm%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=19&zmin=0" target="_blank">https://mt1.google.com/vt?lyrs%3Dm%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=19&zmin=0</a>"<br>GOOGLE_SATELLITE_SOURCE = "type=xyz&url=<a href="https://mt1.google.com/vt?lyrs%3Ds%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=19&zmin=0" target="_blank">https://mt1.google.com/vt?lyrs%3Ds%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=19&zmin=0</a>"<br><br>class WMSTestApp(QMainWindow):<br><br> def __init__(self):<br> super().__init__()<br><br> self.canvas = QgsMapCanvas(self)<br> self.bridge = QgsLayerTreeMapCanvasBridge(QgsProject.instance().layerTreeRoot(), self.canvas)<br> <br> layer = QgsRasterLayer(GOOGLE_SATELLITE_SOURCE, "Test WMS Layer", "wms")<br> <br> QgsProject.instance().addMapLayer(layer)<br> self.canvas.setLayers([layer])<br><br> self.setCentralWidget(self.canvas)<br><br><br>QgsApplication.setPrefixPath(os.environ.get("QGIS_PREFIX_PATH", "C:\Program Files\QGIS 3.4\apps\qgis"), True)<br>qgs = QgsApplication([], True)<br>qgs.initQgis()<br><br>app = WMSTestApp()<br>app.show()<br>qgs.exec_()<br>qgs.exitQgis()</span><br></div><div><br></div><div dir="ltr">Interestingly, the layers (from the same sources!) both load from the Windows QGIS app.</div><div>So
I did some digging and noticed that the default Google Maps url returns
PNG files, while the Satellite url returns JPEGs. I tested a couple of
other links, and it seems like only PNG tile servers have any effect on
windows systems.</div><div><br></div><div>Have tested this on Windows 7 and 10, with the same results.<br></div><div><br></div><div>Does PyQgis need to be reconfigured in some way to get this to work? Or is it a known issue with the version (3.4) I'm using?</div><div><br></div><div>Cheers and thanks,</div><div>Erik</div></div>