Hi experts,
I'm created a web resource to show all child accounts locations on Bing Maps under the parent account record. I got the web resource from here: http://himbap.com/blog/?p=1837
Im not getting any errors but the web resource is blank and not showing the map.
I have entered the correct API.
Here is the code:
<html>
<head>
<script src="../../ClientGlobalContext.js.aspx"></script>
<script src="../Script/SDK.REST.js" type="text/javascript"></script>
<title>Show Child Accounts</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="ecn.dev.virtualearth.net/.../mapcontrol.ashx" type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var messageBox = null;
var lat = null;
var lon = null;
var City = null;
var AccountName = null;
var pushpin = null;
var pushpinCollection = new Microsoft.Maps.EntityCollection();
var messageBoxCollection = new Microsoft.Maps.EntityCollection();
document.onreadystatechange = function ()
{
if(document.readyState == "complete")
{
//initialise map
getMap();
//Get child account records
getChildAccounts();
}
}
function getChildAccounts()
{
//retrieve current entity id
var parentaccountId = window.parent.Xrm.Page.data.entity.getId();
var entitySchemaName = "Account";
//get all child records based on parent customer id
var odataQuery = "?$select=Name,Address1_City,Address1_Latitude,Address1_Longitude&" + "$filter=ParentAccountId/Id eq guid'" + parentaccountId + "'";
if(typeof (SDK) != "undefined")
{
//The retrieveAccountsCallBack function is passed through as the successCallBack.
SDK.REST.retrieveMultipleRecords(entitySchemaName, odataQuery, getnotesImagesCallback, function (error)
{
alert(error.message);
}, function () {});
}
else
{
alert("Not able to load REST.SDK library");
}
}
//callback method
function getnotesImagesCallback(resultSet)
{
//initialise message box
messageBox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0),
{
visible: false
});
messageBoxCollection.push(messageBox);
//Show current account
lat = window.parent.Xrm.Page.getAttribute("address1_latitude")
.getValue();
lon = window.parent.Xrm.Page.getAttribute("address1_longitude")
.getValue();
City = window.parent.Xrm.Page.getAttribute("address1_city")
.getValue();
AccountName = window.parent.Xrm.Page.getAttribute("name")
.getValue();
pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(lat, lon));
pushpin.Description = AccountName + ", " + City;
//show message box on mouse move
Microsoft.Maps.Events.addHandler(pushpin, 'mouseover', displaymessagebox);
//remove message box on mouse lost
Microsoft.Maps.Events.addHandler(pushpin, 'mouseout', hidemessagebox);
pushpinCollection.push(pushpin);
//add collection to map
map.entities.push(pushpinCollection);
map.entities.push(messageBoxCollection);
if(resultSet.length > 0)
{
TotalImages = resultSet.length;
for(i = 0; i < resultSet.length; i++)
{
lat = resultSet[i].Address1_Latitude;
lon = resultSet[i].Address1_Longitude;
City = resultSet[i].Address1_City;
AccountName = resultSet[i].Name;
pushpin = new Microsoft.Maps.Pushpin(new Microsoft.Maps.Location(lat, lon));
pushpin.Description = AccountName + ", " + City;
//show message box on move move
Microsoft.Maps.Events.addHandler(pushpin, 'mouseover', displaymessagebox);
//remove message box on mouse lost
Microsoft.Maps.Events.addHandler(pushpin, 'mouseout', hidemessagebox);
pushpinCollection.push(pushpin);
}
//add collection to map
map.entities.push(pushpinCollection);
map.entities.push(messageBoxCollection);
}
}
function displaymessagebox(e)
{
messageBox.setOptions(
{
description: e.target.Description,
visible: true,
offset: new Microsoft.Maps.Point(0, 25)
});
messageBox.setLocation(e.target.getLocation());
}
function hidemessagebox(e)
{
messageBox.setOptions(
{
visible: false
});
}
function getMap()
{
map = new Microsoft.Maps.Map(document.getElementById('bingMaps'),
{
credentials: 'Aq3qdVGDubWUuklMkomP_2gZqCyzrw_E9vSBD7cOwuGmcvyV2qI2BCIMr_1W8fxP',
center: new Microsoft.Maps.Location(41.956690, -103.137798),
mapTypeId: Microsoft.Maps.MapTypeId.road,
zoom: 10
});
}
</script>
</head>
<body>
<div id="bingMaps" style="width: 600px; height: 500px; position: relative;"></div>
</body>
</html>
What do I have to change in the code for it to start working?
Thanks,
Jon





