V5 bug: Dashboard is not updated when the map style is changed programmatically

Hi,

In V5 we can set the dashboard to one of these three types: VEDashboardSize.Normal, VEDashboardSize.Small, VEDashboardSize.Tiny

Please check this reference for more details:http://msdn2.microsoft.com/en-us/library/bb412545.aspx

The bug is this: when thedashboard type is set toVEDashboardSize.Small, changing the map style from 'road', 'aerial' or 'hybrid' does not update the dashboard icon.

Sad but true. Here is the web page demonstrating this bug:

<html>

<head>

<title>Dashboard icon not updated when changing the map style programmatically</title>

<metahttp-equiv="Content-Type"content="text/html; charset=utf-8"/>

<scriptsrc='http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5'></script>

<scripttype="text/javascript">

var map =null;

var latitude = 47.67;

var longitude = -122.38;

var dashBoardSizes =new Array(VEDashboardSize.Normal, VEDashboardSize.Small, VEDashboardSize.Tiny) ;

var mapStyles =new Array(VEMapStyle.Road, VEMapStyle.Aerial, VEMapStyle.Hybrid) ;

var zoomLevel=6;

function GetMap()

{

map =new VEMap('myMap');

map.SetDashboardSize(dashBoardSizes[1] );

map.LoadMap(new VELatLong(latitude, longitude), zoomLevel ,'r' ,false,VEMapMode.Mode2D);

}

function OnLoadPage()

{

GetMap();

}

function OnUnloadPage()

{

DisposeMap();

}

function DisposeMap()

{

if (map !=null)//dispose the map

{

map.Dispose();

map=null;

}

}

function radioRoad_onclick()

{

ChangeMapStyle();

}

function radioAerial_onclick()

{

ChangeMapStyle();

}

function radioHybrid_onclick()

{

ChangeMapStyle();

}

function ChangeMapStyle()

{

for (var i = 0; i < radioMapStyle.length ; i++)

{

if (radioMapStyleIdea.checked)

{

map.SetMapStyle(mapStylesIdea);

}

}

}

</script>

</head>

<bodyonload="OnLoadPage();"onunload="OnUnloadPage();">

<inputid="radioRoad"style="z-index: 101; left: 64px; position: absolute; top: 496px"

type="radio"name="radioMapStyle"language="javascript"onclick="return radioRoad_onclick()"checked="CHECKED"/>

<divstyle="z-index: 108; left: 200px; width: 312px; position: absolute; top: 472px;

height: 100px">

<p>

When the<strong>dashboard type is set to small</strong>, changing the map style

between 'road', 'aerial' or 'hybrid' does<strong>not</strong> update the<spanstyle="text-decoration: underline">

dashboard icon</span>.</p>

</div>

<inputid="radioAerial"style="z-index: 102; left: 64px; position: absolute; top: 520px"

type="radio"name="radioMapStyle"language="javascript"onclick="return radioAerial_onclick()"/>

<inputid="radioHybrid"style="z-index: 103; left: 64px; position: absolute; top: 544px"

type="radio"name="radioMapStyle"language="javascript"onclick="return radioHybrid_onclick()"/>

<divid='myMap'style="position:relative; width:488px; height:400px; left: 8px; top: 16px; z-index: 100;">

</div>

<divstyle="z-index: 104; left: 88px; width: 100px; position: absolute; top: 496px;

height: 16px">

road</div>

&nbsp;&nbsp;

<divstyle="z-index: 105; left: 88px; width: 100px; position: absolute; top: 544px;

height: 24px">

hybrid</div>

<divstyle="z-index: 106; left: 88px; width: 100px; position: absolute; top: 520px;

height: 24px">

aerial</div>

<divstyle="z-index: 107; left: 64px; width: 88px; position: absolute; top: 472px;

height: 1px; text-decoration: underline">

Map style</div>

&nbsp;

</body>

</html>

[11200 byte] By [AlexandruMatei] at [2008-1-4]
# 1

Yeah, this is a really odd bug. Infact, if you try to switch modes using the dashboard after it bugs out (when you say switch to aerial manually but the dash is stuck on road), a lot of strange behaviour happens. I've re-modified your code below because it was missing some bits:

Code Snippet

<html >
<head>
<title>Dashboard icon not updated when changing the map style programmatically</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 type="text/javascript">


var map = null;
var latitude = 47.67;
var longitude = -122.38;
var dashBoardSizes = new Array(VEDashboardSize.Normal, VEDashboardSize.Small, VEDashboardSize.Tiny) ;
var mapStyles = new Array(VEMapStyle.Road, VEMapStyle.Aerial, VEMapStyle.Hybrid) ;
var zoomLevel=6;


function GetMap()

{
map = new VEMap('myMap');
map.SetDashboardSize(dashBoardSizes[1] );
map.LoadMap(new VELatLong(latitude, longitude), zoomLevel ,'r' ,false,VEMapMode.Mode2D);
}

function OnLoadPage()

{
GetMap();
}


function OnUnloadPage()

{
DisposeMap();
}


function DisposeMap()
{
if (map != null) //dispose the map
{
map.Dispose();
map=null;
}
}


function radioRoad_onclick()
{
ChangeMapStyle();
}

function radioAerial_onclick()
{
ChangeMapStyle();
}

function radioHybrid_onclick()
{
ChangeMapStyle();
}

function ChangeMapStyle()
{
for (var i = 0; i < radioMapStyle.length ; i++)
{
if (radioMapStyle.checked)
{
map.SetMapStyle(mapStyles[0]);
}
else if (radioAerial.checked)
{
map.SetMapStyle(mapStyles[1]);
}
else
{
map.SetMapStyle(mapStyles[2]);
}
}
}
</script>
</head>

<body onload="OnLoadPage();" onunload="OnUnloadPage();" >

<input id="radioRoad" style="z-index: 101; left: 64px; position: absolute; top: 496px" type="radio" name="radioMapStyle" language="javascript" onclick="radioRoad_onclick();" checked="CHECKED" />
<div style="z-index: 108; left: 200px; width: 312px; position: absolute; top: 472px;
height: 100px">


When the <strong>dashboard type is set to small</strong>, changing the map style
between 'road', 'aerial' or 'hybrid' does <strong>not</strong> update the <span style="text-decoration: underline">
dashboard icon</span>.


</div>


<input id="radioAerial" style="z-index: 102; left: 64px; position: absolute; top: 520px" type="radio" name="radioMapStyle" language="javascript" onclick="radioAerial_onclick()" />

<input id="radioHybrid" style="z-index: 103; left: 64px; position: absolute; top: 544px" type="radio" name="radioMapStyle" language="javascript" onclick="radioHybrid_onclick()" />

<div id='myMap' style="position:relative; width:488px; height:400px; left: 8px; top: 16px; z-index: 100;">
</div>
<div style="z-index: 104; left: 88px; width: 100px; position: absolute; top: 496px;
height: 16px">
road</div>

&nbsp;&nbsp;
<div style="z-index: 105; left: 88px; width: 100px; position: absolute; top: 544px;
height: 24px">
hybrid</div>
<div style="z-index: 106; left: 88px; width: 100px; position: absolute; top: 520px;
height: 24px">
aerial</div>
<div style="z-index: 107; left: 64px; width: 88px; position: absolute; top: 472px;height: 1px; text-decoration: underline">
Map style</div>
</body>

</html>

Thanks for reporting this.

DerekChan at 2007-10-3 > top of Msdn Tech,Windows Live Developer Forums,Virtual Earth: Map Control Development...

Windows Live Developer Forums

Site Classified