I am facing issues on adding Multiple layer in Qgis3.0. I tried below code but its not working. I am unable to detect what wrong since its not giving error. Both Layers are valid, but cant be added simultaneously on canvas. I am using python console within QGIS.
from qgis.core import QgsProject
uri='file:///C:/Test/points.csv?delimiter=,&crs=epsg:4326&xField=Lat&yField=Long'
layer=QgsVectorLayer(uri,'Points','delimitedtext')
vectorLyr=QgsVectorLayer("C:/Test/demand/Demand.shp","BuildingLayer", "ogr")
vectorLyr.isValid()
canvas=QgsMapCanvas()
extent=QgsRectangle()
layers[]
layers=[]
QgsProject.instance().addMapLayer(layer)
#<qgis._core.QgsVectorLayer object at 0x00000000055261F8>
extent.combineExtentWith(layer.extent())
layers.append(layer)
QgsProject.instance().addMapLayer(vectorLyr)
#<qgis._core.QgsVectorLayer object at 0x0000000005526318>
extent.combineExtentWith(vectorLyr.extent())
layers.append(vectorLyr)
canvas.setExtent(extent)
canvas.setLayers(layers)
canvas.show()
Please check the sample data https://drive.google.com/open?id=1v5riwWlzkXFhN_FGtawcGhBbmLg49yPn