JavaScript Tutorials
How to Calculate Great Circle Distance (source code)
Color Picker (source code)
How to Calculate Great Circle Distance

Sometimes you need to calculate the distance between two cities. How to do it? You can find the latitude and the longitude of these cities using your map. It is enough to find the distance.

We provide the source code written in JavaScript. Also, you can use the live example to check how it works.
/*f*************/
function calculateGlobeDistance(
 sFromLatitudeDegree,sFromLatitudeMinute,sFromLatitudeSecond,sFromNS,
 sFromLongitudeDegree,sFromLongitudeMinute,sFromLongitudeSecond,sFromEW,
 sToLatitudeDegree,sToLatitudeMinute,sToLatitudeSecond,sToNS,
 sToLongitudeDegree,sToLongitudeMinute,sToLongitudeSecond,sToEW
 )
{
/***********************************************************
  Function returns distance between two points on the Earth
  Latitude of the first point:
   - degrees
   - minutes
   - seconds
   - can be 'N' (North) or 'S' (South)
  Longitude of the first point:
   - degrees
   - minutes
   - seconds
   - can be 'E' (East) or 'W' (West)
  Latitude of the first point:
   - degrees
   - minutes
   - seconds
   - can be 'N' (North) or 'S' (South)
  Longitude of the first point:
   - degrees
   - minutes
   - seconds
   - can be 'E' (East) or 'W' (West)
***********************************************************/
  var nFromLatitude,nFromLongitude,nToLatitude,nToLongitude;
  var qarckm;

  nFromLatitude=convertToDeg(
   sFromLatitudeDegree,sFromLatitudeMinute,sFromLatitudeSecond,sFromNS
   );
  nFromLongitude=convertToDeg(
   sFromLongitudeDegree,sFromLongitudeMinute,sFromLongitudeSecond,sFromEW
   );
  nToLatitude=convertToDeg(
   sToLatitudeDegree,sToLatitudeMinute,sToLatitudeSecond,sToNS
   );
  nToLongitude=convertToDeg(
   sToLongitudeDegree,sToLongitudeMinute,sToLongitudeSecond,sToEW
   );

  qarckm=calculateGlobeDistance_(
   nFromLatitude,nFromLongitude,nToLatitude,nToLongitude
   );

  return qarckm;
}
////////////////*f
function convertToDeg(sDegree,sMinute,sSecond,sDir)
{
  var np;
  if(sDir=='N'||sDir=='E')
    np=sDegree*1+sMinute/60+sSecond/60/60;
  else
    np=-sDegree*1-sMinute/60-sSecond/60/60;
  return np;
}
////////////////*f
function calculateGlobeDistance_(
 nFromLatitude,nFromLongitude,nToLatitude,nToLongitude
 )
{
  var Rad=6372.797;
  var osphFrom,osphTo;

  nFromLatitude*=Math.PI/180;
  nFromLongitude*=Math.PI/180;
  nToLatitude*=Math.PI/180;
  nToLongitude*=Math.PI/180;

  osphFrom=defSphereCoo(Rad,nFromLatitude,nFromLongitude);
  osphTo=defSphereCoo(Rad,nToLatitude,nToLongitude);

  qchordkm=Math.sqrt(
   (osphTo.xp-osphFrom.xp)*(osphTo.xp-osphFrom.xp)+
   (osphTo.yp-osphFrom.yp)*(osphTo.yp-osphFrom.yp)+
   (osphTo.zp-osphFrom.zp)*(osphTo.zp-osphFrom.zp)
   );

  qarckm=2*Rad*Math.asin(qchordkm/2/Rad);

  return qarckm;
}
////////////////*f
function defSphereCoo(rad,nw,nl)
{
  var osph;
  osph=new Object();
  rad_=rad*Math.cos(nw);
  osph.xp=rad_*Math.cos(nl);
  osph.yp=rad_*Math.sin(nl);
  osph.zp=rad*Math.sin(nw);
  return osph;
}

Remarks
passguide 100-105
2016-09-03 00:59:34
http://www.passguides.com/
100-105.html
I read this article because it is not including worthless information. The author clearly describes the information. Thank you for sharing this types article. I am waiting for next article. This is very informative site.
Alpha
2015-12-20 08:46:04

http://www.fantasticgamesbl
og.wordpress.com
Very nice information.
Alpha
2015-12-20 08:45:26
http://www.gamingworld.my
wapblog.com/
Good
Julius
2015-12-20 08:44:14
http://www.techgama.wordp
ress.com
Nice
Picaso
2015-12-20 08:43:09
http://www.fantasticgamesblog.wordpress.com
http://www.techgama.wordpress.com
http://www.gamingworld.mywapblog.com/
kambing
2015-10-15 18:28:10

http://resep4.tumblr.com/
we need this information, i like you site
jordan
2015-10-15 18:27:26

http://bahanmasakan.weebl
y.com/
wow nice information, thanks bro
juliet dalan
2014-05-23 23:06:22
plz...sent my comfirmation code to this no. 09208470660 so that i can open my fb account...plzzzz
disgruntled
2012-10-15 22:31:53
David Kearny is a fuckhead
Add Your Remark:
Your Name*:
Email:
Hide Email    Subscribe to Site News
Web Site:
Message*:
Other tutorials:
Flash Tutorials