The Tile API: Difference between revisions

From University Map Wiki
Jump to navigationJump to search
(Imported)
 
mNo edit summary
Line 61: Line 61:
Map tiles can be retrieved using URLs thus:
Map tiles can be retrieved using URLs thus:


   http://mao.cam.ac.uk/tile/''z''/''x''/''y''.png
   http://map.cam.ac.uk/tile/''z''/''x''/''y''.png


where 
where 

Revision as of 12:49, 27 June 2012

The map is assembled from a grid of image "tiles", each a 256x256 pixel PNG format image representing a small portion of the map in spherical Mercator projection. This is so that as it is panned, images can be loaded or dropped to keep them relevant to the area on view and therefore keep browser memory, bandwidth and download times under control. There is a separate set of tiles for each zoom level. Each higher zoom level doubles the scale and quadruples the number of tiles needed to represent the same area.

While in principle we could use zoom levels from 1, the whole world, to a very large number, in practice the tiles for the University are only generated for levels 13 to 19, so the user should be constrained from going beyond these limits (zoom 19 is equivalent to a scale of about 1 tile to 46m, 0.18m per pixel or 0.66m per mm on a typical display).

Similarly, we don't store tiles for the whole world. We only store the following area (we may constrain this by zoom level also, TBA):

  latitude / longitude tile number at zoom 13 tile number at zoom 19
west TBA TBA TBA
east TBA TBA TBA
north TBA TBA TBA
south TBA TBA TBA

Map tiles can be retrieved using URLs thus:

 http://map.cam.ac.uk/tile/z/x/y.png

where 

  • z is the zoom level
  • x is the tile number in the east/west direction
  • y is the tile number in the north/south direction

This is a conventional form adopted among others by OpenStreetMap for tile presentation. That page also gives the formulae for converting between latitude/longitude and tile number. Rather than managing tiles directly, one could instead present the map itself using an IFRAME as described in The Embedding API and the search/text information in a custom form using the The Database API. The same form of URL is also used by OpenLayers (amongst other interfaces) to display maps; most such interfaces let you plug in the prefix part of the url so that tiles can be obtained from arbitrary sources, and the URLs above are compatible with that.  It is also be possible to overlay information on the tiles obtained from OpenStreetMap's tile server or even on a Google map (whose tiles also use the same projection and numbering scheme).