Shortlink

From OpenStreetMap Wiki
Jump to: navigation, search
Available languages — Shortlink
Afrikaans Alemannisch aragonés asturianu azərbaycanca Bahasa Indonesia Bahasa Melayu Bân-lâm-gú Basa Jawa Baso Minangkabau bosanski brezhoneg català čeština dansk Deutsch eesti English español Esperanto estremeñu euskara français Frysk Gaeilge Gàidhlig galego Hausa hrvatski Igbo interlingua Interlingue isiXhosa isiZulu íslenska italiano Kiswahili Kreyòl ayisyen kréyòl gwadloupéyen Kurdî latviešu Lëtzebuergesch lietuvių magyar Malagasy Malti Nederlands Nedersaksies norsk bokmål norsk nynorsk occitan Oromoo oʻzbekcha/ўзбекча Plattdüütsch polski português português do Brasil română shqip slovenčina slovenščina Soomaaliga suomi svenska Tiếng Việt Türkçe Vahcuengh vèneto Wolof Yorùbá Zazaki српски / srpski беларуская български қазақша македонски монгол русский тоҷикӣ українська Ελληνικά Հայերեն ქართული नेपाली मराठी हिन्दी অসমীয়া বাংলা ਪੰਜਾਬੀ ગુજરાતી ଓଡ଼ିଆ தமிழ் తెలుగు ಕನ್ನಡ മലയാളം සිංහල ไทย မြန်မာဘာသာ ລາວ ភាសាខ្មែរ ⵜⴰⵎⴰⵣⵉⵖⵜ አማርኛ 한국어 日本語 中文(简体)‎ 吴语 粵語 中文(繁體)‎ ייִדיש עברית اردو العربية پښتو سنڌي فارسی ދިވެހިބަސް
The shortlink option in the share tab

A shortlink is a link to a map, designed to be shorter than the normal URL. It can be generated by selecting the Shortlink option on the Share tab.

Example

How the encoding works

The URL is composed of http://osm.org/go/ followed by a binary quadtile address, encoded in ASCII, with chars at the end to indicate relative zoom.

The binary address - for example 0101 - is used as follows. Imagine the lowest zoom tile - this contains the whole globe.

Now - the first bit is 0, this indicates it's the left half of the tile. The second bit being 1 indicates it's the bottom left half in combination with the first bit. The second two bits work the same, further refining the location to the tile that is one sixteenth of the area of the world-tile, on the very bottom-left. (Antarctica, From 45 degrees south down to the pole, and from 90 degrees west to 180 degrees west)

This binary address is then encoded in ASCII, and a few chars are added at the end to indicate relative zoom. The length of the code gives the zoom level rounded to the nearest 3 and the appended code specifies the remainder.

Marker

A marker pin reference for the centre of the map can be added to the shortlink by appending "?m", or by ticking the "Include marker" checkbox on the share tab, or if an alternative map layer or any other query has already been included use "&m". Using one of the above examples, http://osm.org/go/0EEQjE==?m will give the above view with a marker in the centre, http://osm.org/go/0EEQjE==?layers=T&m will give the above view but with the Transport layer selected and a marker in the map centre.

Code for encoding & decoding

You can perform your own shortlink encoding and decoding, and it's worth noting that this is the fundamental advantage of using this URL format over other URL shortening services, where you are dependent on the continuity of that service. With these short links, the location information is truly encoded in the URL, and you can decode it algorithmically, without any database look-up, and independently of OpenStreetMap's servers. Unlike URL shortening services, we're not "using up" combinations of letters. We'll never need to make the URLs longer.

Source code for encoding and decoding shortlinks can be found in the following places:

If anyone has other language implementations, please feel free to link them here.

See also