davek


I have a page that is using v4 to display 2 VEMaps on the same page without any trouble. I tried using v5 yesterday and started getting errors. I get no errors if I only load 1 of the maps though. Any reason I shouldn't be able to use 2 VEMaps on the same page with v5

-davek




Re: Multiple Maps on a Page

Derek Chan


Odd, I don't see any issues loading up two V5 maps without any in depth code applied to it:


Code Snippet
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx v=5"></script>
<script>
var map = null;
var map2 = null;

function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();
map2 = new VEMap('myMap2');
map2.LoadMap();
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
<div id='myMap2' style="position:relative; width:400px; height:400px;"></div>
</body>
</html>


Can you please post sample code to duplicate this problem your having

Thanks,







Re: Multiple Maps on a Page

davek

I was doing something more like this...

map = new VEMap('myMap');

map2 = new VEMap('myMap');

map.LoadMap();

map2.LoadMap();

and I've found it only works when you call LoadMap before initializing map2.

Does this make sense to anyone






Re: Multiple Maps on a Page

Derek Chan

Okay your right doing both back to back causes the error to fire.

I've debugged it in firebug and I think the error "this.vemapcontrol has no properties" is being fired due to the asynchronous nature of map.LoadMap() method. In other words, when map.LoadMap() fires, it allows the next method to fire at the same time (map2.LoadMap()). Then behind the scenes, when its initalizing the map, somehow the API doesn't have enough time to initialize the second map due to interference of the first map causing this particular line to fail:

Code Snippet
if(this.vemapcontrol.IsModeEnabled(Msn.VE.MapActionMode.Mode3D))return VEMapMode.Mode3D;


Basically execute something else before making another call to LoadMap() or put a timer to allow the first map to load might solve the issue.

Hope that helps,