Hi Tom On Wed, Jul 16, 2014 at 3:08 PM, Tom Chadwin <[email protected]> wrote: > In a plugin, we currently loop through all layers in > qgis.utils.iface.mapCanvas().layers. We determine whether a layer is eg WFS > by using QgsVectorLayer.providerType(). However, if OpenLayers plugin layers > are present, this fails: > > AttributeError: 'OpenlayersLayer' object has no attribute 'providerType' > > How should I broaden out the detection of type of layer to determine whether > it is such an OpenLayers layer? I will also then probably want to determine > which OpenLayers layer it is (eg OSM, Google, etc), but for the moment, that > can wait. > > Is there documentation of the OpenLayers plugin suitable for working with it > in plugin development? An API?
Use QgsMapLayer.type() method - it will return one of three values: - QgsMapLayer.VectorLayer - QgsMapLayer.RasterLayer - QgsMapLayer.PluginLayer OpenLayers is plugin layer (providers are used just in vector and raster layers). Type of the plugin layer can be detected from pluginLayerType() method - it will return identifier of that plugin layer as used in QgsPluginLayerRegistry. Regards Martin _______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
