Clone wiki

initiatives-map / Home

Initiatives Map

This repository contains some simple code which was used to produce an online map of healthcare initiatives in England. It uses data from this page, which provides the outlines of all the CCG areas in England.

See it in action here.


  • This example does not include any real NHS initiatives - all data is random words, and is purely to demonstrate the functionality of the code.
  • All code in this repository is open source under the Apache 2.0 license.

Javascript: Google Maps

  • The bulk of the logic resides in the javascript files within the site directory.
  • Google maps v3 API is used to plot the initiatives on a map.
  • Initiatives are plotted in the appropriate CCG areas using the polygon data provided by NHS England.
  • The details of the initiatives themselves are held in a JSON file (data.json), which can be maintained in a content management system to make it easier to make changes as details change.
  • NOTE: No real initiaitive information has been included in this repository, but a sample file data.json.example has been included (you will need to rename this to data.json before use.
  • A range of filters can be applied to allow users to find specific initiatives which may be of interest. Once a CCG region on the map is clicked, the initiatives in that region are listed.
  • The initiatives listed in the map markers are hyperlinks, which can direct the user to more information about the initiative (the URL is also specified in the JSON file).

Java: Supporting Tools

  • The CCG data provided by NHS England (see link above) is in the form of a KML file. This is tricky to use with Google maps, so a small Java utility was created to parse the KML file and turn it into a Javascript file that defines each CCG area in terms of Google Maps "polygons". This is then used to dynamically show the relevant CCG areas in the map as required.
  • The code for this utility is in the src directory of this repository. The build.xml file will build the code and create a jar file using Apache Ant.
  • If you don't want to compile yourself you can use the pre-compiled jar file from the target directory: iCaseUtils.jar


java -cp target\iCaseUtils.jar uk.nhs.icase.converters.KMLtoPolygonConverter "PathToKMLFile"

The generated javascript file will be put into the same directory as the KML file and will always be called ccg.js.

Publishing the Map

Before publishing, it is a good idea to compress the javascript files to improve performance. There are a range of tools available for this, but I have used the Google Closure javascript compiler which works well. Once you have downloaded the jar file for closure, you can use the sample .bat file here to compress the javascript for publication. Compressed files will be created in the /minified subdirectory. The data.json file is loaded dynamically using an Ajax call, so it will need to reside within the same domain as the javascript files to avoid cross-site scripting issues.