Shaun McDonald's Blog My Random Ramblings

 

January 2010
M T W T F S S
« Dec   Mar »
 123
45678910
11121314151617
18192021222324
25262728293031

My Most Recent Flickr Photos

www.flickr.com
smsm1's items Go to smsm1's photostream

Random Flickr Photos

www.flickr.com
smsm1's items Go to smsm1's photostream
  • 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 osm.org. 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:

    http://www.openstreetmap.org/?lat=51.5046&lon=-0.0774&zoom=13&layers=B000FTF

    http://osm.org/go/euu6Ari

    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.

    Published on January 10, 2010 · Filed under: Code, OpenStreetMap;
    2 Comments

2 Responses to “OpenStreetMap Shortlinks”

  1. Kaippally said on

    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

  2. I have updated the post with new links to the git equivalent of the files. I’m not aware of any public PHP code to do it.

Leave a Reply