Monday, December 10, 2018

Modify Google Maps Vector Tiles and Open it in QGIS (Basemap Series Part 5)

It is been a while since last time I discuss about vector tiles basemap. And today I found something cool that may be useful for you too.

As you already know, Google nowadays is also publish it online maps to vector tiles format which make their maps more beauty as well as faster to load.

And because vector tiles based online maps can be stylized in a custom way, there goes also the google maps vector tiles. You can modify how it looks to suit your application needs without spending additional money or resources.

Now, lets go to how to do that.

1. First, go to application that enabling us to customize the Google Maps style using CSS. https://snazzymaps.com is one example. You can explore styles made by other people or make a new style for yourself if you have enough knowledge about CSS.



2. After you find certain style that you are interested in, go to inspect element (chrome) or Firebird (Firefox) and find out the URL for a tile image. Below is an example.

https://maps.googleapis.com/maps/vt?pb=!1m5!1m4!1i15!2i5199!3i11524!4i256!2m3!1e0!2sm!3i368045027!3m14!2sen-US!3sUS!5e18!12m1!1e47!12m3!1e37!2m1!1ssmartmaps!12m4!1e26!2m2!1sstyles!2zcC52Om9uLHMuZTpnfHAudjpvbixzLmU6bHxwLnY6b2ZmLHMuZTpsLnQuZnxwLnM6MzZ8cC5jOiNmZjAwMDAwMHxwLmw6NDAscy5lOmwudC5zfHAudjpvbnxwLmM6I2ZmMDAwMDAwfHAubDoxNixzLmU6bC5pfHAudjpvZmYscy50OjF8cC52Om9mZixzLnQ6MXxzLmU6Z3xwLnY6b2ZmLHMudDoxfHMuZTpnLmZ8cC5jOiNmZjAwMDAwMHxwLmw6MjB8cC52Om9mZixzLnQ6MXxzLmU6Zy5zfHAuYzojZmYwMDAwMDB8cC5sOjE3fHAudzoxLjIscy50OjIwfHAudjpvZmYscy50OjIwfHMuZTpnfHAudjpvZmYscy50OjIxfHAudjpvZmYscy50OjIxfHMuZTpnfHAudjpvZmYscy50OjV8cC52Om9mZixzLnQ6NXxzLmU6Z3xwLmM6I2ZmMjUzYzMyfHAubDoyMHxwLnY6b24scy50OjV8cy5lOmx8cC52Om9mZixzLnQ6ODF8cC52Om9mZixzLnQ6ODF8cy5lOmd8cC52Om9mZixzLnQ6MnxwLnY6b2ZmLHMudDoyfHMuZTpnfHAuYzojZmYwMDAwMDB8cC5sOjIxLHMudDoyfHMuZTpsfHAudjpvZmYscy50OjN8cC52Om9uLHMudDozfHMuZTpnfHAudjpvbnxwLmM6I2ZmYjgxOTE5fHAuczotNDR8cC5sOi0zMixzLnQ6M3xzLmU6Zy5zfHAuYzojZmY2YjU2NTYscy50OjN8cy5lOmx8cC52Om9mZixzLnQ6NDl8cC52Om9uLHMudDo0OXxzLmU6Zy5mfHAuYzojZmYwMDAwMDB8cC5sOjE3LHMudDo0OXxzLmU6Zy5zfHAuYzojZmYwMDAwMDB8cC5sOjI5fHAudzowLjIscy50OjQ5fHMuZTpsfHAudjpvZmYscy50OjUwfHMuZTpnfHAuYzojZmYwMDAwMDB8cC5sOjE4LHMudDo1MXxwLnY6b24scy50OjUxfHMuZTpnfHAuYzojZmYwMDAwMDB8cC5sOjE2LHMudDo1MXxzLmU6bHxwLnY6b2ZmLHMudDo0fHAudjpvZmYscy50OjR8cy5lOmd8cC5jOiNmZjAwMDAwMHxwLmw6MTkscy50OjZ8cy5lOmd8cC5jOiNmZjBmMTkyZXxwLmw6MTd8cC52Om9u!4e0!5m1!5f2&token=27244\

if you open above link in your browser, you will get this tile image.


3. Paste the url in Notepad or any other text editor, and change the URL at this portion (using above URL),
pb=!1m5!1m4!1i15!2i5199!3i11524! to pb=!1m5!1m4!1i{z}!2i{x}!3i{y}!
4. Delete all  characters after "!4e0" , because this custom styles doesn't need API key.

5. The URL now will looks like this :

https://maps.googleapis.com/maps/vt?pb=!1m5!1m4!1i{z}!2i{x}!3i{y}!4i256!2m3!1e0!2sm!3i368045027!3m14!2sen-US!3sUS!5e18!12m1!1e47!12m3!1e37!2m1!1ssmartmaps!12m4!1e26!2m2!1sstyles!2zcC52Om9uLHMuZTpnfHAudjpvbixzLmU6bHxwLnY6b2ZmLHMuZTpsLnQuZnxwLnM6MzZ8cC5jOiNmZjAwMDAwMHxwLmw6NDAscy5lOmwudC5zfHAudjpvb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6MTd8cC52Om9u!4e0 

6. Load your QGIS, and Open the Catalog Window. Go to XYZ Tiles Tab, and Create New Connection.

7. Paste the modified URL to the URL BOX, and give it a title. After you done, load the files to QGIS Canvas using right click of the mouse.

8. Here is an example of the result.







Here is an video tutorial demonstration 



Cool and Cheers!