A few years back I was deemed a heretic by many of my colleagues and friends when I suggested that HTML5 will remove the need for writing many mobile applications. I was pummelled with questions like:
- But how will they work offline?
- Are you saying a browser user experience can rival a platform native one like Apples?
- You do realise that most games require “threading” how you going to do that?
- What about storing data locally, can you do that?
I was able to fend of most of these, but the one I couldn’t at the time was about accessing the device applications like Camera and GPS. Well things have moved on and whilst I am no longer deemed a heretic there are still some corridor’s whispering doubt.
One of the big features of mobile technology used by many apps is the phones location and location based services and application have already been through a huge hype cycle.
Under the catch-all banner of HTML5, although it is a separate subspec, the W3C Geo Location working group are making location based applications a reality for web developers. It has been around a while and hence is fairly mature and stable now.
A device (even a desktop) can provide location information in a number of ways:
- IP Address (this is typically the location of the ISP rather than your machine, but ok if you simply want to check which country the user is in)
- Cell Phone triangulation (only fairly accurate, very dependent on the phone signal so could be problematic in the countryside or inside buildings)
- GPS (very accurate, takes longer to get location, dependant on hardware support and can be unreliable inside buildings)
- Location data can also be simply user defined: however this is dependent on the user entering accurate information.
Of course one of the key concerns will be privacy but the spec covers this with an approach that the requires a user to give permission for location information to be passed to an application. Note the application can only access location information through the browser and not directly e.g. from the GPS device. Hence the browser enforces the user permissions for access.
The Geo Location API allow for both one off request to get the users current location or for repeated updates on the user’s position, developers write simple callback routines for both approaches. The key information provided includes: latitude, longitude and accuracy. Accuracy is a %value of how close the longitude and latitude values are to the user. Depending on the device you may also get additional information such and speed, heading (direction of travel) and altitude.
As per any quality application you process errors accordingly, especially responding to a failure to get hold of location data because of signal issues or other reasons. Hence retrieving location information is fairly simple, the real hardwork is in processing that information and that requires good old fashioned quality programming ;o)
This specification presents a huge opportunity for web developers to create applications once deemed only the domain of platform specific code, and I for one am very excited!