Random Directions Results
Hi Allen,
I have an issue that I've spent a huge amount of time on and tried to the best of my ability to ensure that my logic is not the issue.
So I have a form which a user builds up a route that they traveled for the day. What happens is they add legs. Eg. Leg1: Location A -> Location B. Then display the route on the map. Location A origin, Location B destination. Leg2: Location B -> Location C. Then display the route on the map. Location A origin, Location B WAYPOINT, Location C destination.
Etc.
Now the problem is. It works most of the time but gives me a random result on the odd occasion.
I have made a really basic example and hopefully you'll see the unexpected result:
https://plnkr.co/edit/7LaUNG605TiKQFRdyhBz?p=preview
In the example, Click "Add Leg 1" . Click "Add Leg 2", then Click "Pop Leg" (which will remove the last leg). Add Leg 2, Pop it, repeat and eventually you'll see that C's location will be marked as B. Even though the object that's being given to the ngmap directions is exactly the same.
Please let me know if my problem description is unclear or you don't see the result.
The issue is driving us nuts!
Ciao!
Hmm, I just thought of something.
Could it be that there are watchers on the 'origin', 'waypoints' and 'destination' variables which any change would trigger calling the google directions API? This would mean that when I change the object, all 3 variables are triggered as changed and then the map receives 3 'direction' results (from 3 separate calls) and the map updates to what is being received. If so, the map could receive the incorrect results due to internet speed and update according to the *last * object received from the API which is not necessarily the *last * request that was sent.
Hello?
Im having issues showing alternative directions using the directions directive.
From your example, I find destination is getting changed by adding and poping leg.Unless I am mistaken, your code work as it is coded.
I'm not sure what you mean.
I hope this will help explain:
Say we have 3 locations. A, B, C
We drive from A to B. origin: A destination: B
We then drive from B to C origin: A waypoint: B destination: C
Say I decide that I want to remove C from the route. origin: A destination: B
The logic works in my code, the object is correct but the route doesn't show me the same result 100% of the time. Sometimes it shows A is origin and C is destination, even though the object says A is origin, B is destination.
Add leg 1, add leg 2, pop the leg, add leg 2 again but do it relatively fast. The route is inconsistent to the object what it should be showing according to the object.
LessorMatt could you find a solution to this problem.? i faced the same issue. i can not remove destination from the map after it created once. your plunker has the same problem. click pop leg twice. map object clears but detination line stil exists on the map.
Hi Uguryilmaz, Unfortunately, I have not found a solution for this :( We still have the problem
hi allen, do you have any idea what could be the problem?