Tuesday, March 15, 2016

Bing Map for Account Entity MSCRM

Hi All,

Create a Bing Map based on Latitude and Longitude for MSCRM

var infoboxLayer = new Microsoft.Maps.EntityCollection();
var pinLayer = new Microsoft.Maps.EntityCollection();
function GetMap() {
            var BingMapKey = GetBingMapKey();
            map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {
                credentials:”hdyudyidididididiididdlklklkaksdf”, zoom: 5, center: new Microsoft.Maps.Location(51.5464828, 0.1293497), labelOverlay: Microsoft.Maps.LabelOverlay.hidden
            });
Loopprospect = GetProspectRecords();
Loadmap();
}
Function GetProspectRecords()
{
// Your Account Fetch XML Code Here
}
Function Loadmap(){
//add pushpins
                    pinInfobox = new Microsoft.Maps.Infobox(new Microsoft.Maps.Location(0, 0), { visible: false, offset: new Microsoft.Maps.Point(0, 20) });
                    infoboxLayer.push(pinInfobox);
                    var location = new Microsoft.Maps.Location(Loopprospect[i].attributes.latitude.value, Loopprospect[i].attributes.longitude.value);
                    var pushpinOptions = { icon: serverUrl + '/WebResources/new_RedPushpin' };
                    var pin = new Microsoft.Maps.Pushpin(location, pushpinOptions);
                    pin.Title = Loopprospect[i].attributes.name.value;
                    var getUrlforopenCustomer = serverUrl + "/main.aspx?etc=1&id=" + Loopprospect[i].attributes.accountid.value + "&pagetype=entityrecord";
                    var getSegment = "";
                    var getOpenRevenue = "";
                    if (Loopprospect[i].attributes.new_segment != undefined) {
                        getSegment = Loopprospect[i].attributes.new_segment.formattedValue;
                    }
                    //Check open Revenue
                    if (Loopprospect[i].attributes.openrevenue != undefined) {
                        getOpenRevenue = Loopprospect[i].attributes.openrevenue.value;
                    }
                    pin.Description = "Segment :" + getSegment + "<br/>" + "Open Revenue :" + getOpenRevenue + "<br/>" + "<a target='_blank' href='" + getUrlforopenCustomer + "'>Click to Open Customer</a>";
                    pinLayer.push(pin); //add pushpin to pinLayer
                    Microsoft.Maps.Events.addHandler(pin, 'mouseover', displayInfobox);
                }

                map.entities.push(pinLayer);
                map.entities.push(infoboxLayer);
}
function displayInfobox(e) {
            if (e.targetType == 'pushpin') {
                pinInfobox.setOptions({ title: e.target.Title, description: e.target.Description, visible: true });
                pinInfobox.setLocation(e.target.getLocation());
            }
        }

in the above code am using a Bing map to get Values from Account Entity(Latitude and longitude) and displaying the Value from account Entity.

No comments:

Post a Comment

How to Run Microsoft Flow for Every one Month

Introduction: In this Blog we will see how to Run Microsoft Flow for Every one Month. Implementation Steps:   1. Navigate to  https://make.p...