Pezholio

28 Jan, 2009

Mashing up planning data with Google Maps

Posted by: Pez In: Council Stuff| Web Development

Planning Alerts LogoAsk a council webmaster what service gets used on their site the most, and I’ll bet you £10 they’ll say ‘Planning’. Planning is one of the most controversial subjects that councils (particularly shire districts) have to deal with and almost all councils publish planning application data on their websites.

The trouble is, a lot of this is locked away in ugly, unusable systems that the public hate using (See the star rating of our planning search pages for proof of this), so any opportunity to make getting access to planning data has to be welcomed.

Step forward the lovely people at Planning Alerts. These guys (a lot of whom are on the MySociety dev team, responsible for the lovely FixMyStreet and TheyWorkForYou sites) have built a system that ’screen scrapes’ planning data from over 250 authorities and lets residents sign up for alerts on planning applications in their area.

As well as this, they also have an API ,which returns the data that they’ve lovingly screen-scraped using all manner of clever scripts in a format that anyone can use, you can get data from a single location (be it postcode, latitude / longitude, or even easting and northing) as well as data for an entire authority. It’s this data that we’re going to use for our mashup.

First, check that your council is covered, if it’s not, then get in touch with the Planning Alerts team and there might be someone who can help. If you’re particularly technical, you might even want to write your own screen-scraper (which is what I did)

Once, you’ve got your council, it’s time to grab a feed. Feeds are returned in this format:

http://www.planningalerts.com/api.php?call=authority&authority=[some name]

So, for example, to get the Scottish Borders data, the feed url is

http://www.planningalerts.com/api.php?call=authority&authority=Scottish%20Borders

Try it with your council and check it works. Make sure you replace any spaces with ‘%20′

If the feed is working, now you can use the Google Maps API to display the latest planning applications on your own site.

Firstly, sign up for a Google Maps API key (if you haven’t done already) and put the relevant code in your header:

<script src="http://maps.google.com/maps?file=api&v=2&key=[your api key here]" type="text/javascript"></script>

Then, it’s a simple case of sticking the following code below (in the <head> section as before):

<script type="text/javascript">
var map;
var geoXml;

geoXml = new GGeoXml("Put your GeoRSS url here");

function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("rss_map"));
map.setCenter(new GLatLng(0, 0), 2);

map.addControl(new GLargeMapControl());
map.addControl(new GLargeMapControl());
map.addOverlay(geoXml); }
}

</script>

And, ta da! There you have it, a Google Map of planning applications for your council, it really is that simple!

This approch works for all geoRSS feeds, so if you’ve got any more feeds in that format, you can do exactly the same thing (I’ve done something similar for food safety scores on the Ratemyplace site)

There is one teeny problem, often it can take a few seconds to load the data, stay tuned for part 2 and I’ll let you know how to combat this!

7 Responses to "Mashing up planning data with Google Maps"

1 | alncl

January 28th, 2009 at 7:13 am

Avatar

brill, ace, skill, skillo

Seriously, thanks for that – it has provided the basis for a discussion with our planning and web teams that should see some real results.

2 | Pez

January 28th, 2009 at 8:42 am

Avatar

No probs, just glad to be of service! :)

3 | Andrew Beeken

January 28th, 2009 at 9:27 am

Avatar

Excellent stuff; just to let you know, the first link you posted for the feed is wrong; the second feed (with the actual link on it) is the working one.

Also, an easy, lo-fi way of implementing this (for people who don’t have code level access to their sites) is to simply take the URL into Google Maps and then use the generaed iFrame to push it onto the page.

4 | Pez

January 28th, 2009 at 9:36 am

Avatar

Arrrgh! Well spotted that man! Have a cookie. Or something.

Good call on the iFrame stuff too. Something for part 2 maybe?

5 | Soulla Stylianou

February 2nd, 2009 at 7:01 am

Avatar

if you are interested in google mashups you should check this out http://ideaperformance.com/2009/01/27/birmingham-and-second-life/

6 | Richard Rundle

February 5th, 2009 at 2:56 am

Avatar

Please be careful what you “mash up” with Google Maps, especially if you’re overlaying data derived from Ordnance Survey data. If there’s any exchange of mapping data FROM your server TO google’s, the current Mapping Service Agreement may not permit you to do this, as the Google terms and conditions of use are not compatible with those of the OS.

Your Authority Liaison Officer will have more information on this.

7 | Pez

February 5th, 2009 at 3:38 am

Avatar

Hi Richard,

As far as I’m aware, the data that PlanningAlerts provides is not OS-derived, so the restrictions don’t apply. It’s always worth bearing in mind though. As for the rights and wrongs, I’ll save that for a later rant…

Comment Form

Twitter / @pezholio



Desperate monetisation attempt…