small job for qgis developer: display google road map on the qgscanvas in EPSG:3857 -- 2
Budget: $10 – $30 USD
Here is my code to display google road map on the qgscanvas:
QgsDataSourceUri ds;
ds.setParam("type", "xyz");
ds.setParam("url", QString("https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}"));
QgsRasterLayer* layer = new QgsRasterLayer(ds.encodedUri(), "my map", "wms");
QList<QgsMapLayer*> layers = mCanvas->layers();
layers.insert(0, layer);
mCanvas->setLayers(layers);
mCanvas->setExtent(layer->extent());
but the result display incorrect coordinate, investigate information about provider, I can not found information about CRS, map unit,..... When use QGIS desktop, I can add xyz tile layer using google map to the canvas and right click on layer, choose properties to show information about provider, it allready show crs, unit, bounding box,...
QgsDataSourceUri ds;
ds.setParam("type", "xyz");
ds.setParam("url", QString("https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}"));
QgsRasterLayer* layer = new QgsRasterLayer(ds.encodedUri(), "my map", "wms");
QList<QgsMapLayer*> layers = mCanvas->layers();
layers.insert(0, layer);
mCanvas->setLayers(layers);
mCanvas->setExtent(layer->extent());
but the result display incorrect coordinate, investigate information about provider, I can not found information about CRS, map unit,..... When use QGIS desktop, I can add xyz tile layer using google map to the canvas and right click on layer, choose properties to show information about provider, it allready show crs, unit, bounding box,...