3

In QGIS 2.18.16 I'm using the following code (and it works).

import requests
service_url = "https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}"
service_uri = "type=xyz&zmin=0&zmax=21&url="+requests.utils.quote(service_url)
tms_layer = iface.addRasterLayer(service_uri, "Google Sat", "wms")

How should I modify it to work in the QGIS 2.99?

0

1 Answer 1

6

Here is the answer: https://issues.qgis.org/issues/18078. Thank you @ndawson for help. This code works in QGIS3:

import requests
service_url = "mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}" 
service_uri = "type=xyz&zmin=0&zmax=21&url=https://"+requests.utils.quote(service_url)
tms_layer = iface.addRasterLayer(service_uri, "Google Sat", "wms")
#lyrs=y - hybrid
#lyrs=s - sat
#lyrs=m - road map

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.