Hey, I have a question about my VE Collection code... The code I have is below. I was wondering if there was a way to somehow change the code to make it so it loads as soon as the page is loaded (you dont have to click a load button). If you could help that would be great! Thanks
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>
<script>
var map = null;
var layerid=1;
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();
}
function AddMyLayer(type)
{
var veLayerSpec = new VELayerSpecification();
veLayerSpec.Type = type;
veLayerSpec.ID = layerid;
veLayerSpec.LayerSource = txtSource.value;
veLayerSpec.Method = 'get';
veLayerSpec.FnCallback = onFeedLoad;
map.AddLayer(veLayerSpec);
layerid++;
}
function onFeedLoad(feed)
{
alert('RSS or Collection loaded. There are '+feed.length+' items in this list.');
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
<INPUT id="txtSource" type="text" value="[URL or collection ID]"
name="txtSource">
<INPUT id="loadFeed" type="button" value="Load RSS" name="loadFeed"
onclick="AddMyLayer(VELayerType.GeoRSS);">
<INPUT id="loadCollection" type="button" value="Load VE Collection"
name="loadCollection" onclick="AddMyLayer(VELayerType.VECollection);">
</body>
</html>

VE Collection Question
feiyu
Han Qiao
try this:
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script>
<script>
var map = null;
var layerid=1;
function GetMap()
{
map = new VEMap('myMap');
map.LoadMap();
AddMyLayer();
}
function AddMyLayer()
{
var veLayerSpec = new VELayerSpecification();
veLayerSpec.Type = VELayerType.VECollection; // or VELayerType.GeoRSS if your using that
veLayerSpec.ID = layerid;
veLayerSpec.LayerSource = [URL or collection ID];
veLayerSpec.Method = 'get';
veLayerSpec.FnCallback = onFeedLoad;
map.AddLayer(veLayerSpec);
layerid++;
}
function onFeedLoad(feed)
{
alert('RSS or Collection loaded. There are '+feed.length+' items in this list.');
}
</script>
</head>
<body onload="GetMap();">
<div id='myMap' style="position:relative; width:400px; height:400px;"></div>
</body>
</html>
Then ditch the alert(); when your done testing.
John.
Anuj164
Mike, I ran into the same problem myself. I haven't tried Caleb T's suggestion yet, but what did work for me was to specifically call the two required functions like this
<body onload=LoadTheMap();AddTheCollection();">
This was with IE6.0, and worked fine. When I had AddTheCollection(); nested within the LoadTheMap(); function, it did not work.
bpsmith
Sure! Just add:
map.onLoadMap = AddMyLayer();
before or after your map.LoadMap() call.