developer documentation r17362

Geo-location

The location-aware web has made some big steps forward, and we think this will only grow bigger over the next few years. For this reason we decided to add location-awareness wherever this makes sense.

The features that are currently location-aware are:

Soon we hope to extend this list.

Finding longitude and latitude

There's 2 ways the Upload API accepts longitude and latitude values. It can either be supplied through the POST variables geo_longitude and geo_latitude, or it can be embedded in JPEG's as EXIF data. Currently there are not a lot of camera's that store GPS information within Jpeg's, but the IPhone and modern blackberries are notable exceptions.

For all other media, and most Jpeg's as well, you need to use the POST variables. The big question now is, how to do this?

Power users might have Gears or Geode installed. Using these browser extensions it is often possible to accurately discovering someones location in urban areas. Geode uses standard API's, which are going to be part of the HTML 5 standard. We think these api's are going to get a larger install-base over the next few years. But, neither Geode and Gears are always 100% accurate. Therefore we recommend also giving users the ability to pick their own location using a map. This will work for 100% of the users and is generally very simple.

A simple example:

Search for an address:

Loading map..
Latitude
Longitude

If you have either Gears or Geode installed, your browser will have asked you whether or not you were comfortable with sharing your location and (hopefully!) placed the icon on the right spot. The default location is our office here in Toronto.


Working with the data

This data is exposed in our API's, such as for example the media.getFiles() API. It is possible to filter by a specific areas through a rectangle. You'll need to specify this by supplying the top-left and bottom-right points. This filter is called 'geoBoundaries'. The data is also exposed in our RSS feeds, through the GeoRSS standard.

To avoid making lots of calls to the API, we have some recommendations:

  1. Make sure you cache data in the browser. When a user zooms in and zooms back out it should not be needed to make this call twice.
  2. We recommend only displaying a limited amount of items in any view. Somewhere between 30 and 100 is a good range.
  3. We also recommend sorting the data you receive by some popularity statistic, such as views, hits or comments. When you are showing a limited amount of items per view, you might as well show the 'best' content.
  4. The most important advice: When a user interacts with the map, by going to a different location or zooming, it will be very likely the user will move/zoom multiple times until the 'final destination' is reached. If you make an API call for each of these interactions, you could end up with lots of requests. Therefore we recommend adding a 3 second delay when the user changes the location/zoom level. Make sure that when the user moves the map, you cancel the previous 3 second timeout.
<< 4 Collections 6 Moderation >>