1

I’m writing a stand-alone app using Python and QGIS 2.14.9 (upgrading is not an option). Previous to 2.18, tiled services are not supported directly; you need a plugin like QuickMapServices. I have that installed, and it works within the desktop app.

Now I want to use QuickMapServices from my standalone app. I know how to create a QgsRasterLayer, but how can I create a tiled QuickMapServices layer programmatically?

# Create a normal raster layer
layer = QgsRasterLayer(url_with_params, ‘My Layer’, ‘wms’)

# But how to create a tiled QMS layer?
layer = TiledLayer(?)

I can think of two approaches:

  1. Include the plugin path in my pythonpath, and somehow instantiate a TiledLayer directly.
  2. Create a project in the desktop app which includes a QuickMapServices layer, and load that project in my standalone app.

Is there a better way?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
mark78
  • 83
  • 4
  • read this https://gis.stackexchange.com/questions/14087/generating-tiles-with-qgis and check the plugin code https://github.com/nextgis/quickmapservices/blob/master/src/py_tiled_layer/tilelayer.py – Fran Raga May 16 '19 at 09:15
  • The main problem I've run into is that QuickMapServices assumes it's running as a plugin, and has iface available. For example in tilelayer.py, it does 'from qgis.utils import iface', and uses iface without checking whether iface is None. I'll add some checks and see if I can get further. – mark78 May 22 '19 at 02:08

0 Answers0