Map events not firing in Firefox 2
Thank you.
Thank you.
try{ Code sample taken from Prodactor's post Thank you.
map.LoadMap(new VELatLong(-34.92, 138.59),11,VEMapStyle.Road,false);
}catch(e){
//Browser does not support SGV or VML
}
Firefox is greater than or equal to 5. As Firefox/2.0 has a minor
version less than 5 Virtual Earth thinks that Firefox 2 doesn't support SVG. Here's the code (from veapi.ashx, included via the standard API):
g=new RegExp("Firefox/(.*)"),d=g.exec(navigator.userAgent); if(d[1]){var a=d[1].split("."); if(a){c=a[0]; e=a[1]; if(parseInt(c)>0&&parseInt(e)>=5)
I'm having a go at overriding the userAgent but I think we might have to wait for that code to get changed to check for 1.5 and higher.
// If the browser is Firefox get the version number I hope that helps everyone developing for Firefox 2 until a new fixed of Virtual Earth arrives. I've tested this on IE 6 and 7, Firefox 1.5 and 2.0 - it doesn't alter the behaviour on anything apart from Firefox 2. --
var ffv = 0;
var ffn = "Firefox/"
var ffp = navigator.userAgent.indexOf(ffn);
if (ffp != -1) ffv = parseFloat(navigator.userAgent.substring(ffp + ffn.length));
// If we're using Firefox 1.5 or above override the Virtual Earth drawing functions to use SVG
if (ffv >= 1.5) {
Msn.Drawing.Graphic.CreateGraphic=function(f,b) { return new Msn.Drawing.SVGGraphic(f,b) }
}
// Put your own code below this line
map = new VEMap('map');
Marc Sutton
Codev Ltd
Awesome work Marc.
Who would have thought that you would ever need to look past version 1.x? Reminds me a little of Y2K....
John.
Thanks much, Marc.
Your fix solved the exception I was getting on the veMap.LoadMap function. However, I still can't get the map to actually load in Firefox version 2.
In the status bar, I see a series of messages to the effect "Transferring data from r1.ortho.tiles.virtualearth.net...". (Sometimes it's r0, r2, etc). Eventually the status bar freezes with one of these messages still displayed, and the map never loads.
Any help that you or anyone else can provide would be much appreciated.....
John
Marc-
Thanks for your post. This did in fact fix the majority of the problems we are seeing with Atlas ( http://atlas.freshlogicstudios.com/) running on Firefox 2.
Shawn Miller
John B: Can you post some code to look at or a link to a demo? The loading messages in the status bar are normal as the various map tiles load but you should be seeing the tiles unless you have hidden the container div.
--
Marc Sutton
Codev Ltd
Marc,
Here's the code from the page that doesn't work:
function pageLoad() {// Resize browser and initialize map control
window.moveTo(0, 0);
window.resizeTo(screen.availWidth, screen.availHeight);
$(
'MapTable').height = screen.availHeight - 290;// The following 7 lines of code courtesy of Marc Sutton, found on the MSDN Virtual Earth: Map Control Development forum...var ffv = 0;var ffn = "Firefox/"var ffp = navigator.userAgent.indexOf(ffn);if (ffp != -1) ffv = parseFloat(navigator.userAgent.substring(ffp + ffn.length));if (ffv >= 1.5) { // If we're using Firefox 1.5 or above override the Virtual Earth drawing functions to use SVGMsn.Drawing.Graphic.CreateGraphic=
function(f,b) { return new Msn.Drawing.SVGGraphic(f,b) }}
veMap =
new VEMap('TheMap');try {veMap.LoadMap();
}
catch(e){alert(e)
}
It used to throw an exception in the LoadMap method ('Your web browser does not support SVG or VML...'). Your code fixed that, but now I get the symptoms described in my first post. The div ('TheMap') is not hidden, and the page works normally in IE6 and IE7.
This page uses the Atlas ScriptManager, in case that makes a difference.
Thanks much for following up with me,
John Bendiksen
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Map test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js">
</script>
<script type="text/javascript">
function pageLoad() {
// Resize browser and initialize map control
window.moveTo(0, 0);
window.resizeTo(screen.availWidth, screen.availHeight);
document.getElementById("MapTable").height = screen.availHeight - 290;
// The following 7 lines of code courtesy of Marc Sutton, found on the MSDN Virtual Earth: Map Control Development forum...
var ffv = 0;
var ffn = "Firefox/"
var ffp = navigator.userAgent.indexOf(ffn);
if (ffp != -1) ffv = parseFloat(navigator.userAgent.substring(ffp + ffn.length));
if (ffv >= 1.5) { // If we're using Firefox 1.5 or above override the Virtual Earth drawing functions to use SVG
Msn.Drawing.Graphic.CreateGraphic=function(f,b) { return new Msn.Drawing.SVGGraphic(f,b) }
}
veMap = new VEMap('TheMap');
try {
veMap.LoadMap();
} catch(e){
alert(e)
}
}
</script>
</head>
<body onload="pageLoad();">
<table id="MapTable"><tr><td>
<div id="TheMap">
</div>
</td></tr></table>
</body>
</html>