DEV Community

Yangholmes
Yangholmes

Posted on

Google Maps TMS Service Parameter Analysis

This article was translated, original article here.


1. Preface​​

Google Maps TMS tiles are detailed, high-performance, and free. Many GIS enthusiasts or developers are accustomed to using this service as the base map for their applications. However, Google does not officially recommend using this API, so official documentation cannot be found.

A Google TMS service URL typically looks like this:

https://mt0.google.com/vt/lyrs=y&scale=2&x=6675&y=3572&z=13&s=Galile&gl=cn

Clicking this link opens a tile showing a location in Dongguan City, Guangdong Province, China. If you modify the URL parameters, you'll notice that while the tile location remains the same, the content of the tile changes. This raises the question: how many parameters can be set for the Google TMS service, and what does each parameter mean?

This article attempts to parse the meanings of these parameters.

2. Google TMS URL Format​

https://mt{s}.google.com/maps/vt/[parameters]

mt{s}: Represents the CDN server. Values range from 0 to 3 (parameter detailed in next section).

3. Parameter Explanation​​

  • x​​: X coordinate of the tile.

  • y​​: Y coordinate of the tile.

  • ​​z​​: Zoom level (scale).

  • hl​​: Host language. Value is a language code. See supported languages.

  • gl​​: Geographic location. Value is a country code. See country codes.

This parameter is inferred from Google Search behavior. Setting gl affects tile annotation content (e.g., markers for Paris satellite image differ between gl=CN and gl=HK). Crucially, mainland China uses the GCJ-02 coordinate system; if gl=cn is not set, annotations and the base map will be offset.

  • ​​lyrs​​: Specifies the layer(s). Layer can be one of the following options:

    • h: Roads and labels only (hybrid base map without satellite/terrain)
    • m: Standard roadmap (default base map)
    • p: Terrain map with roads
    • r: Somehow altered roadmap (historical/older style)
    • s: Satellite imagery only
    • t: Terrain (relief) map only
    • y: Hybrid map (satellite imagery with roads and labels)

Multiple values can be combined (e.g., lyrs=s,h represents satellite with roads/labels, equivalent to y).

A version number can be specified immediately after the layer code, separated by @ (e.g., lyrs=s@125 means satellite imagery only, version 125).

  • ​​scale​​: Magnification factor. Can be 1, 2, 3, or 4. Standard tile size is 256x256 pixels.

    • scale=1: No magnification (256x256).
    • scale=2: Magnified 2 times (512x512).
    • scale=3: Magnified 3 times (768x768).
    • scale=4: Magnified 4 times (1024x1024).

Values greater than 4 are ignored.

  • s​​: Authentication string. Changes according to a specific pattern. It can be calculated using logic similar to this code snippet:
'Galileo'.substring(0, (3 * coord.x + coord.y ) & 7 )
Enter fullscreen mode Exit fullscreen mode

(Note: This formula is an observed pattern; Google's exact algorithm may change.)

4. Risks​​

Using a free, undocumented API carries several risks:

  1. ​​Service Discontinuation Risk:​​ The API provider (Google) may disable the service without notice.

  2. Change Risk:​​ The API parameters, behavior, or format may change without notification from the provider and without updated documentation.

  3. ​​Legal Risk for Commercial Use:​​ Using this API in a commercial product may violate Google's terms of service, leading to potential legal issues.

Top comments (0)