I was first made aware of the fact that maps.google.com now uses geolocation by sdwilsh, which is new in Firefox 3.5. But when I loaded maps, I was surprised to see that it didn’t work when I visited the site. And I was using something even more recent than Firefox 3.5, Minefield. Surely, it has geolocation, so what is going on?
The reason maps doesn’t support Minefield is because of *drumrolls* … browser sniffing. Developers… no wait… GOOGLE web developers, I thought we moved on?
The actual bit of code is here unminimized and tidied up ;
function isBrowserGeolocationSupported(){
if (window.navigator &&
navigator.userAgent.search("Firefox") != -1 &&
navigator.geolocation)
return true;
if (window.navigator &&
navigator.userAgent.search("Chrome") != -1)
return Number(String(/Chrome\/[0-9]+/.exec(navigator.userAgent)).substr(7))>=2;
var gearsFactory=null;
The hell? Ok, so I understand they do a bit of browser sniffing because it looks like Chrome had a old/broken implementation of geolocation. But I wish there was a more graceful way of doing this (maybe something like navigator.geolocation.version < 1). One that didn't break every application that may implement geolocation that isn't named Firefox. Because, those exist too.
Tags: browser compatibility, google chrome, Web






