Thanks for any help you can provide on this one!
I’m using Google Maps API V3 to create a tool that lets the user enter a starting point, end point, and multiple waypoints. For an example of multiple waypoints, see: https://developers.google.com/maps/documentation/javascript/directions#Waypoints
Sometimes, however, users enter a bad address or too many waypoints. People were getting upset that their map would not appear and they couldn’t understand why. So, I built an alert system. For example, when the user puts in too many waypoints, they get an alert for the (status == google.maps.DirectionsStatus.MAX_WAYPOINTS_EXCEEDED), and so forth.
Here’s the problem: when a users enters more than one waypoint, Google will not give me the alert for this status:
if(status == google.maps.DirectionsStatus.NOT_FOUND){
alert("Error: One or more of your addresses was not found."); }
When I have ONLY one waypoint, the alert appears just find. Any ideas how I can fix this?
The problem is that you get a different response, ZERO_RESULTS, which you are ignoring. You need to look at any status that is not OK.
Example
Returns ZERO_RESULTS with 2 waypoints. NOT_FOUND with one. Both are errors.