[QGIS-Developer] Detect OpenLayers layer in Python

Martin Dobias wonder.sk at gmail.com
Mon Nov 27 07:15:53 PST 2017


Hi Tom

On Mon, Nov 27, 2017 at 1:03 PM, Tom Chadwin <tom.chadwin at nnpa.org.uk> wrote:
> Hello all
>
> I thought this might have been asked before, but if so, I've failed to find
> it. How do you determine in PyQGIS whether a layer is an OpenLayers plugin
> layer?

Something like this should work: isinstance(layer, QgsPluginLayer) and
layer.pluginLayerType() == 'openlayers'

There may be other types of plugin layers (e.g. crayfish,
quickmapservices), that's why one needs to check the plugin layer type
as well.

Cheers
Martin


More information about the QGIS-Developer mailing list