allenhwkim / angularjs-google-maps

The Simplest AngularJS Google Maps V3 Directive
http://ngmap.github.io
MIT License
1.52k stars 516 forks source link

Fix directions re-render issue #850

Closed CyberAP closed 6 years ago

CyberAP commented 6 years ago

As stated in some issues, directions can break if you subsequently update more than 1 attribute there. For example if you change destination and waypoints it will break at some point. This is caused by miltiple setDirections() calls. I resolved it by creating a request stack with a 20ms window. That should be enough to handle simple routes with Google's limit of 10 joints.

Reports:

  1. https://github.com/allenhwkim/angularjs-google-maps/issues/839
  2. https://github.com/allenhwkim/angularjs-google-maps/issues/618
CyberAP commented 6 years ago

I am not trying to cancel the timeout, but instead I want to destroy an instance of that timeout after it's been executed. I can add $timeout.cancel(); but that wouldn't mean that I won't need to set my timeout to undefined afterwards. There is a way to check if a timeout has ended by checking $$state property, but that's considered a bad practice, so I thought the best workaround would be to simply set it to undefined. If you could help me find a better way of checking for a completed timeout I would be glad to improve this part of code.

Also I don't really know if I should update builds or include them in the pull request. They occasionally got into it, but I need to know if I should add them in the next commit.