[Qgis-user] how to display a part of map
李桐
myculitong at 163.com
Thu Dec 8 03:11:14 PST 2016
hello,
When I first loaded a map,I want to display a part of map,I used Qgsmapcanvas.setextent(),
But the map didn't change. The following code:
QgsMapLayer* Layer = new QgsRasterLayer("Resources/mapdata/zgc.tif", "gdal", false);
if (!Layer->isValid())
{
//QMessageBox::critical(this, "error", "layer is invalid");
return;
}
QgsMapLayerRegistry::instance()->addMapLayer(Layer);
mapCanvasLayerSet.append(Layer);
mapCanvas->setLayerSet(mapCanvasLayerSet);
mapCanvas->setVisible(true);
QgsCoordinateReferenceSystem wgs84(4326, QgsCoordinateReferenceSystem::EpsgCrsId);
QgsCoordinateReferenceSystem web(3857, QgsCoordinateReferenceSystem::EpsgCrsId);
mapCanvas->setDestinationCrs(wgs84);
mapCanvas->setDestinationCrs(web);
mapCanvas->setCrsTransformEnabled(true);
QgsRectangle r(0, 0, 800, 800);
mapCanvas->setExtent(r,true);
mapCanvas->setCachingEnabled(true);
mapCanvas->refresh();
How to use setextent,and how to display a part of map,Can you tell me ?
Thanks for help!!
Li
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20161208/99d560ab/attachment.html>
More information about the Qgis-user
mailing list