Juco


I just upgraded to Firefox 2. Event though this is still a release candidate ( i know ), the map events are not firing on my app. The events in question are "oncontextmenu" and "onchangeview". These are the ones i use at the moment and so i don't know bout the other events. Will Firefox 2 be supported in the near future A lot of people are already switching, and I have to know what to expect (Question for the VE Team)

Thank you.



Re: Map events not firing in Firefox 2

Juco


Thanks to Prodactor i think i solved the problem. It seems that the problem was caused by an exception on map.LoadMap because Firefox seems to not support SVG and VML. So a simple try catch resolves the problem.

try{
map.LoadMap(new VELatLong(-34.92, 138.59),11,VEMapStyle.Road,false);
}catch(e){
//Browser does not support SGV or VML
}

Code sample taken from Prodactor's post

Thank you.





Re: Map events not firing in Firefox 2

Caleb T - MSFT

Yep, we're working on compatability issues now. Thanks!

Caleb






Re: Map events not firing in Firefox 2

Marc Sutton

The problem is that Virtual Earth checks if the minor version of 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.




Re: Map events not firing in Firefox 2

Marc Sutton

I have created a fix that enables Firefox 2 to work with Virtual Earth with all the same features as Firefox 1.5 (polylines, pushpins etc). Add the following code before you create your map (but after you have included the Virtual Earth API):

// If the browser is Firefox get the version number
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');

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.

--
Marc Sutton
Codev Ltd




Re: Map events not firing in Firefox 2

Krela

That works a treat, thank you Marc! :)



Re: Map events not firing in Firefox 2

Juco

Thanks Marc! It also resolves the onLoadMap event not working bug.
Hope the VETeam include the fix for it in the code soon.




Re: Map events not firing in Firefox 2

SoulSolutions

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.






Re: Map events not firing in Firefox 2

John Bendiksen

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





Re: Map events not firing in Firefox 2

smiller

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





Re: Map events not firing in Firefox 2

David Luu

Good work Marc! I'm sure that saved many people from a bunch of headaches!



Re: Map events not firing in Firefox 2

Marc Sutton

No problem, I'm glad it's helped people as a workaround until the new API comes out. I love Atlas by the way Shawn, very beautiful app.

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




Re: Map events not firing in Firefox 2

John Bendiksen

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 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)

}

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





Re: Map events not firing in Firefox 2

Marc Sutton

This code works for me on Firefox 1.5 and 2. I put it in a wrapper page with the only change being using getElementById instead of $ on the third line as I didn't have scriptaculous handy and I added a last close bracket that was missing in the sample:

<!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>




Re: Map events not firing in Firefox 2

masterkenobi

Marc, you are a God amongst men...thank you for that fix! Saved me mucho headache :)