Google Map tile download

All kinds of map downloader to spend money, but too poor to write their own.

address

Tiles address https://mts1.google.com/vt/lyrs= & gl = CN&hl = {type} {language} & x = {x} & y = {} y & z = {} z

Parameters that

  • Lyrs = type

    • h = roads only
    • m = standard roadmap
    • p = terrain
    • r = somehow altered roadmap
    • s = satellite only
    • t = terrain only
    • y = hybrid
  • GL is the coordinate system

    • CN = Chinese Mars coordinate system
  • HL = Map Text Language

    • Useful – CN = Chinese
    • En – US = English
  • X is equal to the horizontal of the tile
  • Y is equal to the vertical of the tile
  • Z = zoom level satellite map 0-14, roadmap 0-17

Calculate the coordinates of XYZ

Google Maps uses a Mercator projection, just remember that, because you’ll need it when you’re working with maps.

Assuming that longitude = LNG, latitude = LAT and zoom level is ZOOM at a certain point, then the corresponding tile coordinates are:

// The total number of tiles in the global map n = 2 ^ zoom; Floor ((LNG + 180.0/360.0) * n); Floor ((LNG + 180.0/360.0) * n); // The current coordinate of the tile is y // -90°~90°, unevenly divided n tangent = Math.tan (Toradians (Lat)); sec = math.sec(toRadians(lat)); y = math.floor((1 - (math.log(tan + sec) / math.pi)) / 2 * n);

When downloading the map, take 2 diagonal longitude and latitude coordinates of a rectangular area, calculate the tile coordinates according to the above formula, visit the tile download address to download and save the picture.

Watch out (pit!)

Horizontal and vertical range of tiles is 0 ~ 2^ Zoom, level 1 1×1, level 2 2×2, level 3 4×4…

It is suggested to download satellite map and road map respectively, and display them in layers in the map display control, so that different contents can be selectively displayed.