Distance between 2 points in V3

2,540 views
Skip to first unread message

Mikoto

unread,
Dec 29, 2009, 10:35:49 AM12/29/09
to Google Maps JavaScript API v3
Hello, i can't find any method in documentation for calculating the
distance between 2 points (with latlng).
Is such method exists in v3 or I should use v2 api?

mattia berlusconi

unread,
Dec 29, 2009, 10:59:39 AM12/29/09
to google-map...@googlegroups.com
You should use direction service http://code.google.com/intl/it-IT/apis/maps/documentation/v3/services.html#Directions


--

You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.



Anthony Puggioni

unread,
Dec 29, 2009, 11:38:32 AM12/29/09
to google-map...@googlegroups.com
It's not exactly what i was looking for. I want to calculate distance between two point in straight line, and i could not find anything in the doc.

Giulio Pons

unread,
Dec 29, 2009, 3:35:41 PM12/29/09
to google-map...@googlegroups.com
You can search on google for the Haversine formula. You can find a javascript implementation in this ruler for google maps v.3:
 
giulio
 
 

--

paul

unread,
Dec 30, 2009, 10:47:42 AM12/30/09
to Google Maps JavaScript API v3
This formula is pretty accurate for calculating distance between two
points. Accuracy will vary by region so do some research to fine tune
it for your target area.

distance = Math.sqrt((69.1*(cy-lat))*(69.1*(cy-lat))+(53.0*(cx-lng))*
(53.0*(cx-lng)));

Reply all
Reply to author
Forward
0 new messages