How to calculate distance between 2 points

I want to implement some tracking points where I need to calculate distance between 2 locations. Do we have any option in tomtom Map for iOS where I can get exact distance between 2 points.


You can use the Routing module to request a route between two points, then you can use obtained TTRouteResult, to get to TTFullRoute, which contains TTSummary with the length of the route.

let distance = routeResult?.routes.first?.summary.lengthInMetersValue

1 Like

but here I don’t have route. I have only starting and ending location. It is like I am tracking user on the go and need to find distance between user’s current location and some destination point.

Do you want to measure it in a straight line?

1 Like

No, Basically I have a circular and rectangular geofences created on map… I want to calculate the distance between the moving user and circumstances or as fences boundary. i.e. how far user is from fences boundary.

Look here, you can check the TTGeofencingReport of the query. It has a property with a list of fences that the point passed in the request is inside of, in ascending order of the distance between the point and the fence. In the item of the list of fences TTGeofencingReportFenceDetails, you can find the distance in meters from the point passed in the request to the closest point of the fence.

1 Like