Calculate distance between two points Google Maps JavaScript

Ravi Kumar
1 min readJan 21, 2020

--

Calculate distance between two points Google Maps JavaScript

In this blog post, you will learn how to calculate the distance between two points using the Google Maps JavaScript API.

Let’s get started with a program. You are given two coordinates (x1, y1) and (x2, y2) of a two-dimensional graph. Find the distance between them.

For example:

Input : x1, y1 = (3, 4) | x2, y2 = (7, 7)
Output: 5

To resolve this we will use the distance formula derived from the Pythagorean theorem as shown below.

distance formula

--

--