hi davie, thanks a lot for your response.
regards, andy ________________________________ From: davie <[email protected]> To: Google Maps API V2 <[email protected]> Sent: Thursday, February 9, 2012 3:49:05 AM Subject: [Google Maps API v2] Re: what is official earth radius in kms for map api 2 Hi For a locator store the Haversine formula will be adequate. This calculates the great-circle distance between two points – that is, the shortest distance over the earth’s surface – giving an ‘as-the- crow-flies’ distance between the points (ignoring any hills, of course!). Haversine formula: a = sin²(Δlat/2) + cos(lat1).cos(lat2).sin²(Δlong/2) c = 2.atan2(√a, √(1−a)) d = R.c where R is earth’s radius (mean radius = 6,371km); note that angles need to be in radians to pass to trig functions! JavaScript: var R = 3959;//miles or var R = 6371; // km var dLat = (lat2-lat1).toRad(); var dLon = (lon2-lon1).toRad(); var lat1 = lat1.toRad(); var lat2 = lat2.toRad(); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; This is used for the SELECT statement in Google's own store locator http://code.google.com/apis/maps/articles/phpsqlsearch_v3.html#outputxml Regards Davie -- You received this message because you are subscribed to the Google Groups "Google Maps API V2" 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. -- You received this message because you are subscribed to the Google Groups "Google Maps API V2" 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.
