When you click on a map and request an address for that exact point, you might expect a perfect match.
But in practice, the returned address can differ slightly from the location you clicked — sometimes by just a few meters, sometimes more.
If you’ve noticed this behavior in your app, you’re not dealing with a bug. It’s a natural result of how reverse geocoding works.
In this article, we’ll explore why the address you get doesn’t always exactly match the clicked map point, and what this means when building map-based applications.
This example uses a simple map demo powered by the Geoapify Reverse Geocoding API , so you can see this behavior in action.
What Reverse Geocoding Actually Returns
Reverse geocoding doesn’t return the exact point you clicked.
Instead, it returns the closest known addressable location in the dataset. That’s a key difference.
Coordinates represent a continuous space — every point on the map has a latitude and longitude.
Addresses, on the other hand, are discrete. They only exist where real-world objects are defined:
- buildings
- entrances
- parcels
- points of interest
So when you click somewhere on the map, the system has to answer a different question:
“What is the nearest meaningful address to this point?”
Not:
“What exists exactly at this coordinate?”
What this means in practice
- Clicking on a road → returns a nearby building or street address
- Clicking inside a park → returns the nearest street or POI
- Clicking near a building → returns the building’s registered address point
Even if the difference is just a few meters, it’s expected behavior.
How Far Is the Returned Location from the Clicked Point?
Once you understand that reverse geocoding returns the nearest address, the next logical question is:
How far is the returned result from the original point?
There isn’t just one answer — because there are two different ways to measure distance.
1. Distance to the Returned Object (Geometry Distance)
When the returned result represents a building or boundary, the distance is calculated between:
- your clicked point
- and the geometry (polygon) of that object
This leads to an important detail:
👉 If your point is inside the building polygon, the distance can be 0,
even if the returned coordinate (for example, the entrance) is several meters away:
{
"results": [
{
"country": "Germany",
"city": "Nuremberg",
"postcode": "90425",
"street": "Pretzfelder Straße",
"housenumber": "15",
"lon": 11.064715,
"lat": 49.4718661,
"result_type": "building",
"formatted": "Pretzfelder Straße 15, 90425 Nuremberg, Germany",
"distance": 0
}
],
"query": {
"lat": 49.47177742331178,
"lon": 11.064803253993091
}
}
Example:
- You click inside a large building
- The address is tied to the entrance
- The API may report distance = 0 (because you are inside the building)
- But visually, the returned point is offset
2. Real Distance Between Coordinates
This is the actual distance between:
- the clicked point
- and the returned coordinate
This is what you usually need if you want to measure the visible offset.
Option 1: Haversine Formula
You can calculate the distance between two coordinates using the Haversine formula:
d = 2r * arcsin(√(sin²((lat2 - lat1) / 2) + cos(lat1) * cos(lat2) * sin²((lon2 - lon1) / 2)))
Where:
-
lat1, lon1= clicked point -
lat2, lon2= returned location -
r= Earth radius (≈ 6371 km)
Option 2: Using Turf.js
If you're working in JavaScript, you can use a geospatial library like Turf.js to calculate distances easily.
@turf/distance handles geographic calculations for you and returns accurate results in different units, so you don’t need to implement the formula manually.
import distance from '@turf/distance';
const from = [lon1, lat1];
const to = [lon2, lat2];
const dist = distance(from, to, { units: 'meters' });
Option 3: Using Geoapify Geometry API
You can also calculate distances using the Geoapify Geometry Operations API.
This API lets you calculate distances between geometries — including points, lines, and polygons — without implementing the logic yourself.
Example request:
POST https://api.geoapify.com/v1/geometry/operation?apiKey=YOUR_API_KEY
{
"operation": "distance",
"point1": {"type": "Point", "coordinates": [lon1, lat1]},
"point2": {"type": "Point", "coordinates": [lon2, lat2]},
"params": {
"units": "kilometers"
}
}
This approach is useful when you want:
- server-side calculations
- consistent results across services
- support for complex geometries (not just points)
It can also be integrated into AI agents or automated workflows, where distance calculations are part of a larger decision-making process (for example, validating locations or triggering actions based on proximity).
Code Sample: Try It on a Map
Seeing this in action makes the behavior much easier to understand.
Try clicking on different locations in this interactive demo:
What to test:
- Click directly on a building
- Click on a road
- Click inside a park or open area
- Click near building edges or entrances
You’ll notice that:
- the returned address doesn’t always match the exact clicked point
- the marker may appear slightly shifted
- results depend on nearby addressable objects
This makes it easier to see how reverse geocoding behaves in real-world scenarios.
How to Handle This in Your App
To avoid confusion when working with reverse geocoding:
- Don’t expect exact matches — results are approximate
- Show both clicked and returned locations if needed
- Use distance thresholds for validation
- Prefer geometry checks (e.g., inside building) for higher accuracy
- Communicate clearly that the address is the nearest one
These small adjustments can significantly improve user experience.

Top comments (0)