Skip to main content
error corrected, is top-left not top-right corner
Source Link
yellowcap
  • 3k
  • 23
  • 37

The values for x and y in this case are probably just indices for an X-Y-Z tilemap. The indices of a TMS service are unitless, they simply count the number of tiles from the top-rightleft corner.

In your example, the _unitsPerPixel function returns the scale of the pixels for the given zoom level. The value is the width and height of one pixel in the units of the projection (which here appears to be lat/lon). When multiplied with the TILE_WIDTH, you get the scale of one tile in the units of the coordinates system you are working in.

With this, the value x * x_extent - 180 (where x is the tile index) gives you a long value minus the "offset" of -180 degrees. The offset is necessary because you start counting from the left to the right. So if the index x is zero, you are on the left edge of the map and the min_long value is -180. So neither x nor y should assume a negative value.

Tile Map Servers are usually built for use on the web, where the library (such as OpenLayers or Leaflet) ask for a tile using only the xyz tile index, and not any spatial querying. For further reading on this see

http://en.wikipedia.org/wiki/Tiled_web_map

Here is a nice visualization of how tile indices work for google maps (note that there are other definitions as well)

http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/

The values for x and y in this case are probably just indices for an X-Y-Z tilemap. The indices of a TMS service are unitless, they simply count the number of tiles from the top-right corner.

In your example, the _unitsPerPixel function returns the scale of the pixels for the given zoom level. The value is the width and height of one pixel in the units of the projection (which here appears to be lat/lon). When multiplied with the TILE_WIDTH, you get the scale of one tile in the units of the coordinates system you are working in.

With this, the value x * x_extent - 180 (where x is the tile index) gives you a long value minus the "offset" of -180 degrees. The offset is necessary because you start counting from the left to the right. So if the index x is zero, you are on the left edge of the map and the min_long value is -180. So neither x nor y should assume a negative value.

Tile Map Servers are usually built for use on the web, where the library (such as OpenLayers or Leaflet) ask for a tile using only the xyz tile index, and not any spatial querying. For further reading on this see

http://en.wikipedia.org/wiki/Tiled_web_map

Here is a nice visualization of how tile indices work for google maps (note that there are other definitions as well)

http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/

The values for x and y in this case are probably just indices for an X-Y-Z tilemap. The indices of a TMS service are unitless, they simply count the number of tiles from the top-left corner.

In your example, the _unitsPerPixel function returns the scale of the pixels for the given zoom level. The value is the width and height of one pixel in the units of the projection (which here appears to be lat/lon). When multiplied with the TILE_WIDTH, you get the scale of one tile in the units of the coordinates system you are working in.

With this, the value x * x_extent - 180 (where x is the tile index) gives you a long value minus the "offset" of -180 degrees. The offset is necessary because you start counting from the left to the right. So if the index x is zero, you are on the left edge of the map and the min_long value is -180. So neither x nor y should assume a negative value.

Tile Map Servers are usually built for use on the web, where the library (such as OpenLayers or Leaflet) ask for a tile using only the xyz tile index, and not any spatial querying. For further reading on this see

http://en.wikipedia.org/wiki/Tiled_web_map

Here is a nice visualization of how tile indices work for google maps (note that there are other definitions as well)

http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/

Source Link
yellowcap
  • 3k
  • 23
  • 37

The values for x and y in this case are probably just indices for an X-Y-Z tilemap. The indices of a TMS service are unitless, they simply count the number of tiles from the top-right corner.

In your example, the _unitsPerPixel function returns the scale of the pixels for the given zoom level. The value is the width and height of one pixel in the units of the projection (which here appears to be lat/lon). When multiplied with the TILE_WIDTH, you get the scale of one tile in the units of the coordinates system you are working in.

With this, the value x * x_extent - 180 (where x is the tile index) gives you a long value minus the "offset" of -180 degrees. The offset is necessary because you start counting from the left to the right. So if the index x is zero, you are on the left edge of the map and the min_long value is -180. So neither x nor y should assume a negative value.

Tile Map Servers are usually built for use on the web, where the library (such as OpenLayers or Leaflet) ask for a tile using only the xyz tile index, and not any spatial querying. For further reading on this see

http://en.wikipedia.org/wiki/Tiled_web_map

Here is a nice visualization of how tile indices work for google maps (note that there are other definitions as well)

http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/