Hi all,
I'm trying to change a web resource to use the new V8 controls. I have the below HTML that works in V7 but in V8 the map displays correctly with the current pushpin but doesn't show any of the pushpins retrieved with the odata / REST services.
I've looked in the V8 SDK and it seems to use layers for multiple pushpins but only shows examples with the test data generator.
Should this still work with V8 or do I need to change to use layers?
<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="www.bing.com/.../mapcontrol" 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 entitySchemaName = "Account";
//get all child records based on parent customer id
var odataQuery ="?$select=Name,Address1_City,Address1_Latitude,Address1_Longitude&$filter=BusinessTypeCode/Value eq 100000023";
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),{ color: 'orange' });
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() {
c_lat = window.parent.Xrm.Page.getAttribute("address1_latitude").getValue();
c_lon = window.parent.Xrm.Page.getAttribute("address1_longitude").getValue();
map = new Microsoft.Maps.Map(document.getElementById('bingMaps'), {
credentials: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
center: new Microsoft.Maps.Location(c_lat, c_lon),
mapTypeId: Microsoft.Maps.MapTypeId.aerial,
zoom: 10
});
}
</script>
</head>
<body>
<div id="bingMaps" style='width: 600px; height: 500px; position: relative;'></div>
</body></html>
Thanks,
Terry
*This post is locked for comments
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156