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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.