File tree 1 file changed +9
-2
lines changed
1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -203,7 +203,15 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
203
203
204
204
bool goodDirn = false ;
205
205
206
- if ( mapCanvas->layerCount () > 0 )
206
+ // Get the shown extent...
207
+ QgsRectangle canvasExtent = mapCanvas->extent ();
208
+ // ... and all layers extent, ...
209
+ QgsRectangle fullExtent = mapCanvas->fullExtent ();
210
+ // ... and combine
211
+ QgsRectangle extent = canvasExtent.intersect ( & fullExtent );
212
+
213
+ // If no layers are added or shown, we can't get any direction
214
+ if ( mapCanvas->layerCount () > 0 && ! extent.isEmpty () )
207
215
{
208
216
QgsCoordinateReferenceSystem outputCRS = mapCanvas->mapRenderer ()->destinationCrs ();
209
217
@@ -216,7 +224,6 @@ bool QgsDecorationNorthArrow::calculateNorthDirection()
216
224
217
225
QgsCoordinateTransform transform ( outputCRS, ourCRS );
218
226
219
- QgsRectangle extent = mapCanvas->extent ();
220
227
QgsPoint p1 ( extent.center () );
221
228
// A point a bit above p1. XXX assumes that y increases up!!
222
229
// May need to involve the maptopixel transform if this proves
You can’t perform that action at this time.
0 commit comments