I am trying to use a PCF control in one of my canvas app where I am displaying Azure maps using a dataset template. Before showing the data push pins using latitude and longitude, I am trying to get the distance of each push pins from a default location and see whether the distance is within a particular radius or not, and then decides whether to display the pushpin or not. For this purpose, I am using the below code. This line of code throws below exception inside the canvas app but at the same time works fine in the test harness. I have cross-checked all the objects here and nothing is null. I have also checked the passing unit as a parameter thinking that could be a possible issue but with that parameter also the result is the same. Any suggestions or support regarding the same would be really appreciated.
let distanceFromCurrentLocation = atlas.math.getDistanceTo(
new atlas.data.Position(this.defaultLongitude,this.defaultLatitude),
new atlas.data.Position(longitude,latitude))/1000;