I am confused a bit, using addVectorLayer() in QGIS plugin.
I want to add and display a vector layer, directly when QGIS opens. Hence I am using addVectorLayer() in _init_() function of my plugin. The problem I am seeing is, the vector layer is loaded in the legend but is not displayed on the canvas. I, manually have to click on "zoom to layer extent", to display it.
Any hints on how to solve this problem will be of high help to me.
NOTE: If I use either of the below, it works perfect (i.e. the layer is loaded and displayed as well).
- qgis.exe D:/sample.shp at the command prompt OR
- In QGIS Plugin, If I use addVectorLayer() on some menu item click