So I'm working in a project that needs a feature to identify when an object (in my case a car) is currently in front or behind another one using Google Maps. I currently have the bearing (cars orientation) and the distance between both cars.
So far my approach is that if car2 has the same bearing as car1 and the distance between both cars is reducing, car1 gets an alert that car2 is behind. But, this only work if I'm in car1. car2 will also receive a false alarm saying that car1 is also behind him, wich is not true (car1 is on front). This is because I don't know which car is getting close to the other one due to the fact that I only have distance between them.
So the question is: Is there a way to know when a location is getting close to another one with the GPS and GoogleMaps? Maybe comparing Lat and Lon between both?