Google Maps - How to get the distance between two point in metre?

I think you could do without any specific API, and calculate distance with plain Javascript:

This site has good info about geographical calculations and Javascript sample for distance calculation.

Ok, quick glance at Google API page and it seems, you could do it by:

  1. Call DirectionsService().route() to get DirectionsResult with routes
  2. For one or each route go through its legs property and calculate sum of distances

If you're looking to use the v3 google maps API, here is a function to use: Note: you must add &libraries=geometry to your script source

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=geometry"></script>

<script>
var p1 = new google.maps.LatLng(45.463688, 9.18814);
var p2 = new google.maps.LatLng(46.0438317, 9.75936230000002);

alert(calcDistance(p1, p2));

//calculates distance between two points in km's
function calcDistance(p1, p2) {
  return (google.maps.geometry.spherical.computeDistanceBetween(p1, p2) / 1000).toFixed(2);
}

</script>

http://www.csgnetwork.com/gpsdistcalc.html

Has nothing to do with coding btw

EDIT if you're looking for some code

Calculate distance between two points in google maps V3