[QGIS-Developer] PyQGIS WMS tiles don't load on Windows

Jonathan Moules jonathan-lists at lightpear.com
Tue Apr 9 09:25:01 PDT 2019


Hi Erik,

I think maybe there's a nomenclature problem here. I wasn't aware that 
any Google services were available via WMS.

WMS is a specific specification, and if you're googling around using 
that term you're going to find results that aren't pertinent to what you 
actually want to do (which is using Google's tile based, non-WMS services).

Cheers,

Jonathan


On 2019-04-09 08:54, Erik Polzin wrote:
> 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.
>
> Here is a test script I wrote to demonstrate the problem:
>
> from qgis.core import QgsApplication, QgsProject, QgsRasterLayer
> from qgis.gui import QgsMapCanvas, QgsLayerTreeMapCanvasBridge
>
> from PyQt5.QtWidgets import QMainWindow
> import os
>
> GOOGLE_MAPS_SOURCE = "type=xyz&url=
> https://mt1.google.com/vt?lyrs%3Dm%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=19&zmin=0
> "
> GOOGLE_SATELLITE_SOURCE = "type=xyz&url=
> https://mt1.google.com/vt?lyrs%3Ds%26x%3D%7Bx%7D%26y%3D%7By%7D%26z%3D%7Bz%7D&zmax=19&zmin=0
> "
>
> class WMSTestApp(QMainWindow):
>
>      def __init__(self):
>          super().__init__()
>
>          self.canvas = QgsMapCanvas(self)
>          self.bridge =
> QgsLayerTreeMapCanvasBridge(QgsProject.instance().layerTreeRoot(),
> self.canvas)
>
>          layer = QgsRasterLayer(GOOGLE_SATELLITE_SOURCE, "Test WMS Layer",
> "wms")
>
>          QgsProject.instance().addMapLayer(layer)
>          self.canvas.setLayers([layer])
>
>          self.setCentralWidget(self.canvas)
>
>
> QgsApplication.setPrefixPath(os.environ.get("QGIS_PREFIX_PATH", "C:\Program
> Files\QGIS 3.4\apps\qgis"), True)
> qgs = QgsApplication([], True)
> qgs.initQgis()
>
> app = WMSTestApp()
> app.show()
> qgs.exec_()
> qgs.exitQgis()
>
> Interestingly, the layers (from the same sources!) both load from the
> Windows QGIS app.
> 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.
>
> Have tested this on Windows 7 and 10, with the same results.
>
> 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?
>
> Cheers and thanks,
> Erik
>
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190409/3aa7090e/attachment.html>


More information about the QGIS-Developer mailing list