Wajdi Methlouthi
asked on
nan value
im getting NaN result !!
distance(lat1, lon1, lat2, lon2) {
this.R = 6371; // RadparseIntius of the earth in km
this.dLat = this.deg2rad(lat2 - lat1); // deg2rad below
this.dLon = this.deg2rad(lon2 - lon1);
var a =
Math.sin(this.dLat / 2) * Math.sin(this.dLat / 2) +
Math.cos(this.deg2rad(lat1)) * Math.cos(this.deg2rad(lat2)) *
Math.sin(this.dLon / 2) * Math.sin(this.dLon / 2);
this.c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
this.d = this.R * this.c; // Distance in km
return this.d;
}
What do you get with ?
could you give the values you get in the alert?
could you give the values you get in the alert?
distance(lat1, lon1, lat2, lon2) {
alert(lat1 + " / " + lon1 + " / " + lat2 + " / " + lon2 );
return 12.34;
}
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
How are you calling it?