Wi-Fi Trilateration Using Node.js

It’s different from triangulation

Photo by NASA on Unsplash

Wi-Fi trilateration (also referred to as multi-lateration) is the technique used to estimate the position of a client’s device based on relative distance from the positions of available Wi-Fi access points. This is in contrast to Wi-Fi triangulation, which determines positioning based on the angles of arrival (AoA) of signals received by the antennae of the access points.

Image illustrating GPS trilateration from GISGeography

In the above image, you can see three GPS satellites with a certain radius. Suppose your location is within the range of all three of these satellites. Based on the position and radius of these three access points, your potential position can be determined using trilateration by finding the point at which they all intersect.

For Wi-Fi trilateration, you can imagine these satellites as wireless access points, and you are able to reach all of them. This means that your device is in range of all these access points. The space in which these access points meet is the space that your device falls under.

Picture this scenario. You are trying to make a script that will grab a user’s geographic location (latitude and longitude) and use those coordinates to recommend restaurants nearby. To do this in the browser, you would use the Location object. However, you cannot access the browser’s location via the command line.

How can we use JavaScript to get the user’s device coordinates without the browser? If we can gather various wireless access points around the user’s device, we can use Wi-Fi trilateration to get the device coordinates.

Here’s what we’ll need.

node-wifiscanner — This npm package is what will be used to gather wireless access points near you. You can install it by doing npm install node-wifiscanner .