How to check if a point/address lies on a route?  Gautam Thakur  11/27/11 2:22 PM  Hi there, I have a set of latitude and longitude and I want to know if between 
Re: How to check if a point/address lies on a route?  yip cto  11/28/11 10:13 AM  You can use the directions service to generate a route and then check 
Re: How to check if a point/address lies on a route?  Gautam Thakur  11/28/11 12:42 PM  Thanks It worked. I also did the same after trying other things. got the route and all the coordinates of polyline. then just used the distance between two points function to get the minimal with a threshold set. On Nov 28, 1:13 pm, yip cto <cto...@googlemail.com> wrote:> > two end points, are there any of the other locationlie? Is it > You can use the directions service to generate arouteand then check

Re: How to check if a point/address lies on a route?  winster jose  11/11/12 9:19 PM  Hi Gautam, Can you please share your findings? I have a similar requirement. I have a group of points (LAT/LON). When user selects a route (it can be any route), I need to show the points from my group if they lie in the requested route. Also how can we do it with a better performance? I think, once the user searches for a route, find the max and min LAT/LON, and get the points from my group. But still how to find out whether a point lies in route? Thanks Winster 
Re: How to check if a point/address lies on a route?  Nitin Surana  12/19/12 11:21 AM  hello Gautam & Winster, have you guys figured out a solution ? Please share to help others like me. 
Re: How to check if a point/address lies on a route?  Jonathan Kraemer  12/30/12 7:24 AM  Hey Winster, I developed something that might help, please got o my app, which is participating on Google Places API Developers Challenge: http://enchentes.org , move the slider on the top right corner to 12m, for instance (doing that, the app will show flood spots on that level for a specific city) and get some directions by right clicking on the map > Get Directions From/To Here. You will see that routes that pass through the flood spots become red. If you like it, please vote for my app on the challenge: https://developers.google.com/places/challenge/gallery I can share with you guys how I did that if you think it solves the issue. BR, Jonathan Em segundafeira, 12 de novembro de 2012 03h19min53s UTC2, winster jose escreveu: 
Re: [Google Maps API v2] Re: How to check if a point/address lies on a route?  winster jose  1/4/13 7:06 AM  Hi Jonathan,
Good work! I've given my vote. You may have come across a scenario what I am searching for. I have a list of points on map. I need to check which of these points lie on a route.
Regards Winster 
Re: [Google Maps API v2] Re: How to check if a point/address lies on a route?  montelpz  1/4/13 7:51 AM  Hi Jonathan.
If you can, please share with us your app. Thanks in advance. Carlos Montelongo 2013/1/4, winster <wtj...@gmail.com>: 
Re: [Google Maps API v2] Re: How to check if a point/address lies on a route?  Jonathan Kraemer  1/7/13 5:46 AM  Hey guys,
The problem of just checking the distance from the point to the route is that it will give a false positive in cases the point is actually after the end of the route or before the beginning, for instance.
What I did there is actually pure math. See: the route is actually a bunch of lines. Using math you can get the equation of a line and using math functions, get the distance from a point to a line, plus check if the projection of a point lies inside the limits of the line. The tricky part is that in order to do all this calcs, we need the start/end point of the route lines and the points positions as a cartesian system, instead of latitude, longitude angles, X and Y dimensions in meters. That's not a problem actually, with a good enough approximation, we can convert lat,lon angles to X,Y distances. The result is not perfectly accurate, but it's proven that it is enough, I did not see cases of false positives in my app yet.
Knowing that, here is more or less how I solved this: First of all, I am using the version 3 of the Google Maps API. So first step I make a look through all the points at the array overview_path that the directions API returns. So I make this loop from position 0 to "length1" because overview_path contains points and I want to read always the current point AND the next one, so I have a line.
But before calculating any information, I convert the coordinates to meters. With that in hands, I get the line equation, which is pure math. And again using math, calculate the distance from each point to the line and also project the point to the line and check if it is inside the limits (the initial and final points I am considering).
Now that I know if the point is in the limits and the distance from the point to the line, I can check if it is close enough that I can consider that point "in" the route. I am not sure if it is understandable for you guys, let me know and I will try to make it simpler, I can share the code with you guys or I can create a "service" so you can just load in your apps and use it, what do you think?
BR, Jonathan 
Re: [Google Maps API v2] Re: How to check if a point/address lies on a route?  Jonathan Kraemer  1/7/13 5:47 AM  Sorry, let me explain: I had to "project" the points to the line because we can't expect the point we want to check will be exactly in the line we are checking.
BR,
Jonathan 