UK Map and API Data WordPress Integration

To create UK Maps of the data from the Governments Petition Data

Taking WordPress into the realm of deciphering geodata JSON data obtained via a RESTful API, and integrating with a UK MAP of the constituencies. Petition JSON data is available from the UK government website and we wanted visitors to the website to select a petition and be able to hover over the UK map to view number of votes within that area.

Interactive Map WordPress

The Approach

I researched several approaches and investigating the mapping library to be used within WordPress. Whenever a JSON is used in a project, the data has to be analysed and verified that we don’t need any other data from a different in order to be able to create a meaningful map.
The map of England in GeoJson format was found and we were then able to create the WordPress page.

For this particular implementation we didn’t want to hold the data in the database. We do a call each time the user selects a different petition to view. However we could add the petitions into the database, creating a custom post type, running an import on a regular basis via a cron job. This would then lend itself to potential organic traffic if we also considered the meta data when we imported it.

The Outcome

The visitor can select a petition from a drop down, and the map is then filled with the information of the petition. When the visitor hovers over an area of the map, information for that area is displayed on the page