I had the same problem in a C++ application.
this sounds like the mapRenderer's labelingEngine of your canvas is not defined.
here is what i have done (in C++) :
#include <qgspallabeling.h>
...
QgsPalLabeling *labelingEngine = new QgsPalLabeling();
mCanvas->mapRenderer()->setLabelingEngine(labelingEngine);
I think you could do something like this in python :
from qgis.core import QgsPalLabeling
...
labelingEngine = QgsPalLabeling()
yourCanvas.mapRenderer().setLabelingEngine(labelingEngine)
with this, i have labels loaded properly using customProperties from qml.
Locking layers will certainly work, but I wanted to make sure there were a few other methods represented in the answers here.
I'll work with the following lines layer. As you can see, the features are already labeled.
![roads](https://i.stack.imgur.com/UR70i.png)
Method One: Data-Driven Solution
Data-driven solutions are my favorite, because if you do them right, they always work. To set this up, first go to your layout, and under the Item Properties of your main map, set the Item ID to something. I've chosen Map 1
.
![map id properties](https://i.stack.imgur.com/zkTgC.png)
We'll need to use Rule-based labeling. Open up the default rule that appears.
![rule-based label](https://i.stack.imgur.com/Vs1VF.png)
In the Filter text box, enter the expression @map_id IN ('Map 1', 'canvas')
. We put canvas
in there to ensure that we can still see the labels in our main window.
With that filter in place, only Map 1 will have labels, regardless of layer locks, styling, scale, etc.
![id-based labeling](https://i.stack.imgur.com/JCJjl.png)
Method Two: Scale-based Labels
Given that overview maps are smaller scale than their counterpart maps, you can also set a scale boundary on your labels. This method only requires a single layer, and no themes or locking on the Layout view.
Again, we'll use Rule-based labeling. You don't actually have to establish any rules, though. Simply apply a minimum scale which is larger (i.e., a smaller number) than the scale of your overview:
![scale based labels](https://i.stack.imgur.com/ufGpD.png)
![scale based label maps](https://i.stack.imgur.com/TgpRH.png)
Method Drawbacks
It's minor, but if you are adjusting the size and scale of your layout items, you may need to adjust the value on your label scale limit.
Method Three: Map Themes and Duplicate Layers
Establish the Main Theme
Get your map styled the way you want in your map. In the Layers pane, click on the Manage Map Themes (the eyeball) icon, then select Add Theme... and name it however you like. I'll name mine "Main Theme".
![enter image description here](https://i.stack.imgur.com/vHe4f.png)
Duplicate Layer and Establish Overview Theme
Right-click your labeled layer in the Layers pane and select Duplicate Layer. Rename the new layer something like "Your Layer - Overview".
In the Layer Styling pane, turn the labels off for this new layer. With the new layer on and the original off, add a new theme. Mine will be called "Overview".
If you are doing this with multiple layers, you may want to add groups to your Layers pane.
![layers panel with groups](https://i.stack.imgur.com/u7osD.png)
Layout: Link Maps to Themes
In you layout view, select your main map. Under Item Properties, check the box next to Follow map theme and select the "Main Map" theme. Do the same for the overview map, selecting the corresponding theme.
![two maps with different layer themes](https://i.stack.imgur.com/iZozy.png)
Method Drawbacks
Using this method does have the drawback that your layer symbols are separate. Changing the styling of one will not automatically update the other. To get around this, you can right-click one layer and copy its symbology, then right-click the other and paste it. The Copy Style menu allows you to copy the symbols only, so you can safely avoid adding labels to the other layer.
![copy symbology only](https://i.stack.imgur.com/XaWwD.png)
Best Answer
This is not ideal, but if you are OK with the label always appearing on the marker, you can use a background on your label as a workaround.
Downsides:
An example that takes a file name from "field_1" and removes the .jpg extension to form label text for photo locations:
The results:
zoomed in:
and zoomed out: ![zoomed out](https://i.stack.imgur.com/H05zG.png)
(note - the direction the svg icon points was set by an expression referencing another field in the table)