OpenStreetMap Shortlinks

Shortlinks were introduced to OpenStreetMap at the end of June 2009, by Matt Amos, as a way to have a short url to get to a specific point on the map. It is a method to go from the code to a latitude, longitude and zoom. It also works in the reverse direction too. You will see the shortlink in the bottom right hand corner of the map on If you have a location that you want to show to people, say on twitter, then the shortlink may be a nicer method than using the standard tinyurl services.

Here is an example of the difference:

You can even add markers by appending ?m to the end of the short link and the marker will appear in the centre.

If you are a developer you may want to include support for the shortlink, in addition to or instead of the standard permalink. A good example is if your app sends twitter messages with your current location, where there is a limited number of characters that can be used, thus a shorter url is needed.

For some code take a look at the bottom of the site.js file, site_controller and the shortlink library.

Update: With the move of the OpenStreetMap codebase having moved from svn to git the new file locations are: sites.js, site_controller.rb, and the ruby shortlink library.

2 Replies to “OpenStreetMap Shortlinks”

  1. I would like to know how I can generate the shortlink from within my webserver in PHP. The openstreetmap wiki briefly discuses how the shortcode is produced, and provides a ruby script. I am not familiar with Ruby. If there is a JSON RPC that produces the shortcode that will also be great.

    The .js links you provided do not work. where can I get this .js

    Thanks in advance

Leave a Reply