Posted By

ginoplusio on 11/08/08


Tagged

maps map distance googlemaps


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

luman
not_skeletor
jsalo


Distance between two points


 / Published in: PHP
 

URL: http://www.barattalo.it

  1. //$lat1 = 46.2341938036161;
  2. //$lon1 = -63.124778021257015;
  3. //$lat2 = 46.4141938036161;
  4. //$lon2 = -63.118571124705284;
  5.  
  6. function distance($lat1,$lon1,$lat2,$lon2) {
  7. return (3958*3.1415926*sqrt(($lat2-$lat1)*($lat2-$lat1) + cos($lat2/57.29578)*cos($lat1/57.29578)*($lon2-$lon1)*($lon2-$lon1))/180);
  8. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Scooter on November 8, 2008

Should use a constant for pi instead of a magic number.

You need to login to post a comment.