Navigation Menu

Skip to content

Commit

Permalink
Fix map view synchronization with different CRS
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 13, 2017
1 parent 560e9c2 commit 419e53b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/app/qgsmapcanvasdockwidget.cpp
Expand Up @@ -14,6 +14,7 @@
***************************************************************************/
#include "qgsmapcanvasdockwidget.h"
#include "qgsmapcanvas.h"
#include "qgscsexception.h"
#include "qgsprojectionselectiondialog.h"
#include "qgsscalecombobox.h"
#include "qgsstatusbarmagnifierwidget.h"
Expand Down Expand Up @@ -194,7 +195,18 @@ void QgsMapCanvasDockWidget::mapExtentChanged()
syncView( false );

QgsMapCanvas *destCanvas = sourceCanvas == mMapCanvas ? mMainCanvas : mMapCanvas;
destCanvas->setExtent( sourceCanvas->extent() );

// reproject extent
QgsCoordinateTransform ct( sourceCanvas->mapSettings().destinationCrs(),
destCanvas->mapSettings().destinationCrs() );
try
{
destCanvas->setExtent( ct.transformBoundingBox( sourceCanvas->extent() ) );
}
catch ( QgsCsException & )
{
destCanvas->setExtent( sourceCanvas->extent() );
}
destCanvas->refresh();

syncView( true );
Expand Down

0 comments on commit 419e53b

Please sign in to comment.