iOS Only Kills - Open Data Saves Lives

by @edent | # # # # | 6 comments | Read ~1,146 times.

A slightly tongue-in-cheek title for quite a serious subject.

The South Central Ambulance Service NHS Foundation Trust have a list of emergency defibrillators available for public use. To help raise awareness, they've released an app...

Of course, it's iPhone and iPad only. Who cares if Android, BlackBerry, or Windows users want to save a life, right?

Rather than doing anything constructive with my day, I snarked on Twitter.

Well, how hard can it be to plot points on a map? So, I threw myself into the challenge over my lunch break. Turns out, it's really easy. You can play with my demo on your phone.

AED Mobile Web Screenshot Detail

Getting the Data

The NHS provided me with a link to a Google map:

https://maps.google.com/maps/ms?authuser=0&vps=5&ie=UTF8
&hl=en&oe=UTF8&msa=0&output=kml
&msid=213551442652291377405.0004daf3ca79fc04df02e

It's really easy to get Google Maps to spit out KML. All you really need is the msid:

https://www.google.co.uk/maps/ms?ie=UTF8&hl=en&vps=1&jsv=280a
&msa=0&output=kml
&msid=213551442652291377405.0004daf3ca79fc04df02e

Hey presto - one KML file.
AED Mobile Web Screenshot Map

Drawing The Map

Google Maps is so passée - and hides some fairly nasty gotchas - so I used OpenStreetMap. I find that OpenLayers is the easiest way of making OpenStreetMap look beautiful on mobile - and it natively supports KML imports.

AED Mobile Web Screenshot no streetview

Finding Oneself

A user, presumably, wants to find the closest AED to where she is right now - so I wanted to geolocate the user's phone. The OpenLayers geolocation code was a bit to complex for a very quick hack, so I just went with

navigator.geolocation.getCurrentPosition(function(position) {
var lonLat = new OpenLayers.LonLat(position.coords.longitude,
                                   position.coords.latitude)
             .transform(
                new OpenLayers.Projection("EPSG:4326"), //transform from WGS 1984
                map.getProjectionObject() //to Spherical Mercator Projection
             );
   map.setCenter(lonLat, 15 // Zoom level - Not too far in, or the user may not see what's going on.
   );
});

Feedback

One satisfied customer 🙂

Open Data + Open Source = Big Win For Society

Improvements

This was a quick hack, to be worked on by others with more free time. Here are some things which need changing.

  • The KML file is static - ideally it should be loaded dynamically from a canonical source.
  • Geolocation doesn't track the user. Ideally she should see if she's getting closer to an AED.
  • Pins could do with being bigger, and perhaps a different colour.
  • Needs links to official sources so the user can trust it.
  • Needs an icon so the user can install it to the screen of her phone.
  • Potential to use HTML5 to cache the KML file for offline use.

If you want to play around with the code - it is available on GitHub.

6 thoughts on “iOS Only Kills - Open Data Saves Lives

  1. msaspence says:

    Check out leaflet, much better option to open layers

    1. I've used Leaflet - but couldn't find an easy way to import KML. Do you know a simple way to get it working?

  2. Upload the kml to cartodb.com. After upload you have a nice gui for manipulating the data. Use the cartodb sql api to download data to your client, or (the super-easy way) use the cartodb html map client.

  3. An alternative - and I would say better - approach would be to enter the data directly into OSM, and then to make your own render of it, using the tools and styles of your preference. The data would then be available to anyone wanting to render or otherwise reuse, or improve it, along with that of neighbouring providers.

    The important thing in that case would be to ensure that any updates made by South Central Ambulance Service NHS Foundation Trust (and doesn't that just trip off the tongue!) are mirrored in the OSM database. That could mean SCASNHSFT making the changes, or pushing the info to the OSM community or a willing third party. If only there were a mobile telephony company interested in facilitating such public service...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.