Microsoft Virtual Earth on Firefox 2

Microsoft Virtual Earth (Microsoft’s competition to Google Maps and the excellent Yahoo! Maps) doesn’t believe that Firefox 2 can support SVG: the way they check for SVG support is if the user agent matches the regexp “Firefox/(.*)“, and if the version number (the .*), when split on ‘.‘, has a major version greater than 0 and a minor greater than 2. That is: they believe that only Firefox versions .*\.[5-9].* supports SVG. This totally ignores e.g. Firefox

Here’s a hack around it (not a proper fix): before you initialize the map, overwrite the Msn.Drawing.Graphic.CreateGraphic method:

function initMap() {
  Msn.Drawing.Graphic.CreateGraphic = function(f,b) {
          if (document.all) return new Msn.Drawing.VMLGraphic(f,b);
          else {
            var d = new RegExp("Firefox/(.*)").exec(navigator.userAgent);
            if(d[1] && parseFloat(d[1]) >= 1.5) 
                  return new Msn.Drawing.SVGGraphic(f,b)
            throw new Msn.Drawing.Exception(L_GraphicsInitError_Text)
  // Standard code from here on out:
  map = new VEMap('the-map');
  // ...
%d bloggers like this: