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;
Experts... any support or suggestions would be really appreciated. Thanks in advance.
Hi @renjithpradeep ,
I have never used Azure maps, but the distance between two points can be calculated (in klm) with
With(
{
wLat1: YourFirstLatitude,
wLat2: YourSecondLatitude,
wLong1: YourFirstLongitude,
wLong2: YourSecondLongitude,
wCalc: 0.0174532925199432
},
12742 *
Asin(Sqrt(0.5 - Cos((wLat1 - wLat2) * wCalc)/2 +
Cos(wLat1 * wCalc) * Cos(wLat2 * wCalc) * (1 - Cos((wLong1 - wLong2) * wCalc)) / 2))
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
User | Count |
---|---|
152 | |
100 | |
89 | |
78 | |
58 |
User | Count |
---|---|
194 | |
188 | |
106 | |
99 | |
91 |