Sunday, March 11, 2018

This is How to Add Google Maps Layers in QGIS 3

Finally QGIS 3 was released and I am so pleased for that. QGIS 3.0 Girona brings many features and updates such as improved geometry editing, symbols, layout, 3D layer, etc. What about plugins? I found many plugins already ported to QGIS 3, but unfortunately not all, including one of my favorite OpenLayers plugin, which can be used to add Google Maps basemap into QGIS map canvas such as Google Satellite, terrain and road map. What could we do to add those Google Maps layers in QGIS 3.0? Is there any other way around so we can still use Google Map in QGIS? The answer is Yes and I will show it in this tutorial.

Google Maps Layer is hosting somewhere in Google server and sends the tile to the user who request it. Technically we call this as Tile Map Service (TMS). So, we just need to find the TMS which Google uses to serve Google Maps layers. After searching for a while, finally I found the Google Maps Layer TMS from NextGIS that are listed below:
  • Google Maps: https://mt1.google.com/vt/lyrs=r&x={x}&y={y}&z={z}
  • Google Satellite: http://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}
  • Google Satellite Hybrid: https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}
  • Google Terrain: https://mt1.google.com/vt/lyrs=t&x={x}&y={y}&z={z}
  • Google Roads: https://mt1.google.com/vt/lyrs=h&x={x}&y={y}&z={z}  

Adding Google Maps Layers in QGIS 3

Then how to add the Google Maps tile service in QGIS 3? Simply, we uses XYZ Tiles. For example we want to add a Google Maps layer as a basemap. We can do it with the following steps:
1. Make a new connection, with right click the XYZ Tiles as in figure 1.

Make a new connection in XYZ Tiles
Figure 1. Make a new connection in XYZ Tiles
2. Give the name, for example: Google Maps.  In the URL copy and paste the Google Maps TMS above. Set the max zoom level to 19. See figure 2.

XYZ Tiles connection details
Figure 2. XYZ Tiles connection details
3. Add the Google Maps XYZ tiles connection that already created to the QGIS layer. The Google Maps layers basemap will be added to the QGIS map canvas direclty as in figure 3.

Google Maps Layers in QGIS
Figure 3. Google Maps Layers in QGIS
 
With the same steps, the other Google basemap layers like Google Terrain, Google Satellite, etc, can be added to QGIS 3. I captured some of the results in the images below.

Google Terrain Layer in QGIS 3
Figure 4. Google Terrain Layer in QGIS 3

Google Satellite Layer in QGIS 3
Figure 5. Google Satellite Layer in QGIS 3
Great, now we can add a basemap from Google Maps layer in QGIS 3, even without any plugin. Hope this tutorial helps :)

8 comments :

  1. Hi. Thanks for this. I added Google Maps but the text is too small to see. Is there a way to make the text bigger?

    ReplyDelete
    Replies
    1. I don't think so, because the service just render/display the tile from server. Nothing we can do to modify or alter the map. The only option is to zoom in for your interest area and the text will looks bigger, because the text size will change inversely with map scale

      Delete
  2. Hi, thanks for this. I'm wondering why max zoom level should be 19? If I use a higher number would I get better resolution? Thanks

    ReplyDelete
    Replies
    1. I think it is the max zoom level for the tile as refer to the TMS info at https://qms.nextgis.com/. You could try to give a higher number, but not sure will give a better resolution

      Delete
  3. Thank You, this tutorial is very useful.

    ReplyDelete
  4. This was great! I was trying to find a plug in to follow a tutorial online, but was unsuccessful. Your solution worked and allowed me to continue. Thanks!

    ReplyDelete