# Identifying waypoints on a route • ### Question

• I'm using the following example to generate a route:

https://msdn.microsoft.com/en-us/library/ff701717.aspx?f=255&MSPPError=-2147217396

Is it possible, give a specific latitude, longitude to identify whether that point is on the generated route?  Ideally, with a specified margin of error (for example, within 1/2 mile of the route)?

Friday, March 24, 2017 6:49 PM

• The route service won't tell you if some arbitrary coordinate is on the route path. This is something that can be calculated afterwards.

If using .NET the SQL Spatial tools (available as a .NET library and doesn't actually require SQL) to calculate this.

If using JavaScript, the Bing Maps V8 control has a spatial math module which provides similar functions.

Using either of these you can do the following:

• Take the route path information from the REST service response and create a LineString (SQL) or Polyline (V8) object.
• Use the spatial math function to calculate distance.

I've put together a code sample that you can try here: http://bingmapsv8samples.azurewebsites.net/#Calculate%20Distance%20From%20Route

• Proposed as answer by Friday, March 24, 2017 8:15 PM
• Marked as answer by Saturday, March 25, 2017 10:33 AM
Friday, March 24, 2017 8:15 PM

### All replies

• The route service won't tell you if some arbitrary coordinate is on the route path. This is something that can be calculated afterwards.

If using .NET the SQL Spatial tools (available as a .NET library and doesn't actually require SQL) to calculate this.

If using JavaScript, the Bing Maps V8 control has a spatial math module which provides similar functions.

Using either of these you can do the following:

• Take the route path information from the REST service response and create a LineString (SQL) or Polyline (V8) object.
• Use the spatial math function to calculate distance.

I've put together a code sample that you can try here: http://bingmapsv8samples.azurewebsites.net/#Calculate%20Distance%20From%20Route

• 