anybody knows the distance calculation formula which uses Google in
maps api?
JavaScript:
pline = polylineEncoder.dpEncodeToGPolyline(verts);
map.addOverlay(pline);
pLen = parseFloat(pline.getLength());
I need to do the same, but in php code.
I tried this way:
-------------
$path = 0;
for($i=0;$i<sizeof($traceMv)-1;++$i)
{
$lon1 = $traceMv[$i]['longitude'];
$lat1 = $traceMv[$i]['latitude'];
$lon2 = $traceMv[$i]['longitude'];
$lat2 = $traceMv[$i+1]['latitude'];
$line = floatval(substr(111.2*acos(sin($lat1) * sin($lat2) + cos
($lat1) * cos($lat2) * cos($lon2-$lon1)),0,10));
$path += $line;
}
$path = round($path,3);
-------------
Sometimes it works, but doesn't match google's a bit. And sometimes
result is unexpected:
google's result: 408 meters
php: 23 km 103 m
Rows in $traceMv have such structure:
id, latitude, longitude.
Help please
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---