Measure distance on Google Maps by adding a draggable ruler

How to measure distance on Google Maps with a free tool online made with Javascript

Free tool online to measure distances on Google Maps

Your search for "distance google maps" get the right result! Here is how to measure distances on a Google Map with simply 3 steps, follow these instructions and use the free online tool in this page:

  1. Choose a new location and press Go there.
  2. Or stay here and press Add A Ruler button to add a ruler
  3. Drag the markers to make the measure.

You can add many rulers by pressing the button again. When you add a ruler, to see the ruler line drag one of the markers, because they are one over each other. To delete a Ruler from the Google Map, just double click on a marker of the ruler (thanks to Bernhard Konrad for this feature).

The geocoding conversion from a string to Latitude and Longitude coordinates is made with my Minibots class.

How to add a ruler on a Google Map to measure distance with Javascript

This ruler to measure distances is made with Javascript and can be used on any Google Maps if you're able to make some code in Javascript. When you press the button it inserts in the map object two Google Maps Markers with a line. The file Ruler.js that does the trick contains two functions: one to calculate the distance between two points on the map with their position expressed in decimal degrees, and one function that add the ruler to the map object. The “ruler” is composed with two marker objects, a poly and two labels which show the distance. The labels are placed on the map with the Labels.js class from Marc Ridley. To get the code and download everything, please go to this page which is more technical.

Distance between two points on a sphere

To measure the distance between two points of the map this ruler uses a formula that is more accurate than the Pythagorean theorem, because it measures the distance between two points on a sphere using Trigonometry. It is more accurate than assuming that the Earth is flat, but it's not perfect beacuse the Earth isn't a perfect sphere. But it's enaugh, especially if you have to measure distances on Google Maps that are not too big.

If you want to convert an address to GPS coordinates, use my GPS coordinates converter tool.