GPolyline.getLength() simply runs along the vertexes performing
GLatLng.distanceFrom(), and summing the results.
The last time I looked, .distanceFrom() used the simple spherical
algorithm. That algorithm is known to be poorly conditioned when dealing
with short distances, but because Javascript uses double precision
arithmetic, the error is usually less than a metre.
If you've got lots of points in your 10 metre line, then those errors
could mount up.
If you want really accurate results, you could run along the vertices
and use either the Havesine or the Vincenty algorithm to obtain each
distance, which should give you millimetre accuracy. The significant
difference between Vincenty and Havesine is that Vincenty takes into
account the fact that the Earth isn't a perfect sphere, but that
shouldn't have any measurable effect on such a short distance.
distHaversine = function(p1, p2) {
var R = 6371; // earth's mean radius in km
var dLat = rad(p2.y - p1.y);
var dLong = rad(p2.x - p1.x);
var a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(rad(p1.y)) * Math.cos(rad(p2.y)) * Math.sin(dLong/2)
* Math.sin(dLong/2);
var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
var d = R * c;
return d;
}
--
http://econym.org.uk/gmap
The Blackpool Community Church Javascript Team
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---