Experiences with HTML5 mapping
We have recently been updating our IP Mapping Joomla component to handle HTML5 geolocation detection and thought this may be of interest to others.
IP Mapping was originally designed with the aim of displaying IP addresses upon Google Maps and experience has shown that although it works well it is very reliant upon the accuracy of the data held by the various database and communication suppliers. The various supplied of the IP to location mapping vary considerably in the accuracy of the location information. We ourselves have been ‘located’ as being several hundred miles away from where we were physically located, depending upon which IP-location provider we were using and when we were determining the location. Whilst this may be adequate for some, for others it is a little bit hit and miss. I am thinking here of a ‘local’ village or town intending to serve the local neighbourhood, who desire to know how widespread their visitors are.
HTML5 geolocation offers an alternative mechanism to the IP address mapping offered by the various vendors. If enabled a check is first performed to determine whether a user's browser is capable of supporting HTML5 geolocation and if it is, a request is then made to obtain the information. If successful this is then used to display the location upon a map. If unsuccessful, or if the browser does not support HTML5 geolocation, the fall back, existing IP mapping is used instead.
Privacy is an obvious concern when one is involved with sharing your physical location with a remote web server. The geolocation API explicitly states: “User Agents must not send location information to Web sites without the express permission of the user.” In other words, sharing your location is always opt-in. If you don't want to, you don't have to.
The geolocation API lets one share your location with trusted web sites. The geolocation API is supported by most browsers on the desktop and mobile devices.
The geolocation API centres around a new property on the global navigator object: navigator.geolocation.
Important: The HTML5 geolocation is asynchronous which means that there may be a delay before an actual location is stored with in the database and the visitor displaying the page.
There are several web sites on that go into details of how it is implemented which I will not repeat here, but it was very easy to implement and accurate to within a few hundred yards or less. The most obvious use is for this sites that offer directional information to enable one to get from Point A to Point B, and with HTML5 geolocation they are immediately aware of where Point A is physically located. Our specific implementation was only concerned with obtaining the location once, and we had no interest in knowing if they were moving, so we set the refresh calls to a large value.
One particular problem we did encounter was that there were situations where the request for the location never returned to our caller. The situation where the user decided to just ignore (or close) the popup opt-in info bar (sharing request window), is not handled in the consistently by all of the populate browsers. Indeed they often tended to have slightly different options for the user to select. We had to implement a windows timeout so that if we never received any feedback we could take our default action, which was to use an IP location mechanism. Once this was working we found that it was reasonably efficient, although being asynchronous it did mean that there was a small delay before the visitor location information was stored in our database.
Perhaps one of our main concerns was how site visitors would react to this request for location sharing. Our experiences with smartphones, and small tablets indicate that the information sharing is often turned on by default, which is not the situation with stand alone PC or even laptop PCs. I suspect that most smartphone and tablet users may well be unaware they are sharing their location anyway. We expect that this optional feature will not be of use for every site, but certainly from the feedback we have received from the users of our component they do desire as accurate a location as possible for their site.