Geotagging and GeoRSS support has been available in Elgg for a little while now, but like so many cool features of the platform, I haven’t really had the time to draw people’s attention to it.

Although I am drawing your attention to it now, it should be noted that this is still somewhat under development!

Anatomy of a geocoder

To begin geocoding your data you will need a geocoder. This is not something that Elgg comes installed with by default, although here’s one I coded earlier.

This geocoder users the Google maps API to do the actual encoding, and provides two primary features.

  • It handles the plugin hook “geocode”,”location”
  • It listens to all create events and attempts to tag it with the latitude and longitude – either from a ->location metadata on the object itself, or from the user’s current ->location – you could get more creative, this is a simple example.

When you attempt to geocode a location you call the function elgg_geocode_location(). This in turn triggers the above plugin hook and attempts to encode the data.

For efficiency once a location has been geocoded the result is cached. Future attempts to code the same location will return the result from the cache.

Once installed and configured, new content (wire posts etc) will be tagged with a latitude and longitude. Fill in your profile location field and try it out for yourself!

Location based searches

Once things are tagged with a location, you can start to use location as a starting point for searching by using some of the location aware search functions in location.php.

This hasn’t currently been hooked up to the Elgg interface in any way, but that doesn’t stop you making use of it in your plugins.


This is something you’ll be pleased to know that you get for free!

As you list your entities using the Elgg listing tools using the RSS view, if an entity has a position defined it will be included using standard geoRSS simple notation, i.e:

<georss:point> 45.256 -71.92 </georss:point>

Happy coding!

3 thoughts on “Geocoding Elgg entities

  1. I’m not sure if anyone has touched it since I put it in to tell the truth!

    I doubt it’s been removed, but I’m not sure if anyone has done any more work on it.

    Still, it’s looking as if it might be something I’m going to have to look at for some client work I’m doing. Any improvements I make I’ll put on this blog and push upstream, so you might see them in 1.8 🙂

Leave a Reply