Skip to content
Permalink
Browse files

Ensure map is centered when updating map extent (fix #6988)

  • Loading branch information
nyalldawson committed Oct 28, 2013
1 parent 969ddf5 commit 5aac8bbfe060502944b4b4cc3bfb00860b583e98
Showing with 8 additions and 4 deletions.
  1. +8 −4 src/app/composer/qgscomposermapwidget.cpp
@@ -179,15 +179,19 @@ void QgsComposerMapWidget::on_mSetToMapCanvasExtentButton_clicked()

if ( currentWidthHeightRatio < newWidthHeightRatio )
{
//enlarge height of new extent
//enlarge height of new extent, ensuring the map center stays the same
double newHeight = newExtent.width() / currentWidthHeightRatio;
newExtent.setYMinimum( newExtent.yMaximum() - newHeight );
double deltaHeight = newHeight - newExtent.height();
newExtent.setYMinimum( newExtent.yMinimum() - deltaHeight / 2 );
newExtent.setYMaximum( newExtent.yMaximum() + deltaHeight / 2 );
}
else if ( currentWidthHeightRatio > newWidthHeightRatio )
{
//enlarge width of new extent
//enlarge width of new extent, ensuring the map center stays the same
double newWidth = currentWidthHeightRatio * newExtent.height();
newExtent.setXMaximum( newExtent.xMinimum() + newWidth );
double deltaWidth = newWidth - newExtent.width();
newExtent.setXMinimum( newExtent.xMinimum() - deltaWidth / 2 );
newExtent.setXMaximum( newExtent.xMaximum() + deltaWidth / 2 );
}

//fill text into line edits

0 comments on commit 5aac8bb

Please sign in to comment.
You can’t perform that action at this time.