Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Getting error while accessing the Microsoft.Maps.Location in JavaScript

$
0
0

Hi,

I am looking into to get the distance between locations (using Bing Map) in Javascript but getting the error "Cannot read property 'Location' of undefined" error.

The Microsoft.Maps.Location method causing issue. Can anyone help how to fix this issue?

 

Below is my JavaScript code:  

function distanceCalculation(executionContext) {
var formContext = executionContext.getFormContext();

var hLatitude = "17.38405";
var hLongitude = "78.45636";

var bLatitude = "12.971599";
var bLongitude = "77.594566";

getDistanceBetweenLocations(new Microsoft.Maps.Location(hLatitude, hLongitude), new Microsoft.Maps.Location(bLatitude, bLongitude));

}


// Calculate distance between two locations.
function getDistanceBetweenLocations(Location1, Location2) {
Microsoft.Maps.loadModule('Microsoft.Maps.SpatialMath', function () {
var vDistance = Microsoft.Maps.SpatialMath.getDistanceTo(Location1, Location2, Microsoft.Maps.SpatialMath.DistanceUnits.Miles);
alert("Distance in Miles : " + vDistance);
});
}

Thanks,

Naveen


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images