This is the code that i used and in this code first i make an web resource of Rest.SDK,js file
and then i make an another web resource which code is given below.
Now, please explain what should i do?
<html>
<head>
<script src="../../ClientGlobalContext.js.aspx"></script>
<script src="new_/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 ()*/
function loadingmap()
{
if(document.readyState == "complete")
{
//initialise map
getMap();
alert("after get map");
//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,Address2_Latitude,Address2_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("address2_latitude")
.getValue();
lon = window.parent.Xrm.Page.getAttribute("address2_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: 'Aq3qdVTUDrWUuklMkomP_2gZqCyzrw_E9vgnD7cOwuGmcvyV2qI2BCIMr_1W8fxP',
center: new Microsoft.Maps.Location(41.956690, -103.137798),
mapTypeId: Microsoft.Maps.MapTypeId.road,
zoom: 10
});
}
</script>
<script type='text/javascript' src='www.bing.com/.../mapcontrol;callback=loadingmap' async defer></script>
</head>
<body onload="loadingmap()">
<div id="bingMaps" style="width: 600px; height: 500px; position: relative;"></div>
</body>
</html>