The map on the home page of Drupal.org is one of the most-noticed new features. It started with the prototype, which was just that— a Flash-based idea for what might go there. During implementation, we had to figure out what exactly it would be and how it would work.

First, we needed to know where people were. Drupal.org has the advantage of an audience who is more-likely to be using modern browsers, and we don’t need everyone’s location. I decided we should use the new Geolocation API, but didn’t find any existing modules. I wrote a small HTML5 user geolocation module to add a share location option to your profile page. For privacy, it is opt-in and rounded to the nearest 0.1 longitude/latitude. Over 5,000 have shared their location, less than 1% of active Drupal.org users, but still looks impressive on a map:

World map of Drupal.org users who have shared their location.

(The map was made with TileMill and this shapefile.)

With user locations, we can query for actions on the site for the home page. Since no other sites will be looking for documentation updates, forum posts, and commits, this is custom code in Drupal.org customizations. The map itself is not exactly “live,” the last 30 actions are included in the page. The queries are only executed every 5 minutes and cached so no page request has to wait for them.

As usual with Drupal 7, all of this should be more straightforward. Geolocation Field has a selector widget based on HTML5 User Geolocation, for any fieldable entity. I haven’t had a chance to try it, but the idea is Views and OpenLayers can do the maps.

Comments

inkling’s picture

The custom code link is broken. I haven't been able to find the code elsewhere. Is it still available?

piotrdesign’s picture

I'm also looking for this code. Can anyone help us please?

britneyb’s picture

can someone fix this? im really having trouble using this code... 

 

Free instagram followers

baisong’s picture

Here's a snapshot of the code mirrored on GitHub:

For more up-to-date code, you can download the drupalorg module to your local machine: