Google Maps Uncaught TypeError: Cannot Read Property 'start_location' Of Undefined In Google Maps
Hi I have this simple function in JS for google maps and I get uncaught typeerror directionResult is google directions response object which is passed by other function to this fu
Solution 1:
Hard to tell without more information but I would check that the myRoute.steps array contains at least three elements.
Solution 2:
The error is the length of myRoute.steps [myRoute.steps.length]
var myRoute = directionResult.routes[0].legs[0];
var warnings = document.getElementById("warnings_panel");
for (var i=0;i<myRoute.steps.length;i++)
{
warnings.innerHTML += "<br/><br/>start lat = " + myRoute.steps[i].start_location.lat() + "start lng = " + myRoute.steps[i].start_location.lng() + "<br />";
warnings.innerHTML += "end lat = " + myRoute.steps[i].end_location.lat() + "end lng = " + myRoute.steps[i].end_location.lng() + "<br /> + Path :";
for(var path=0;path<myRoute.steps[i].path.length;path++)
warnings.innerHTML += myRoute.steps[i].path[path];
}
Post a Comment for "Google Maps Uncaught TypeError: Cannot Read Property 'start_location' Of Undefined In Google Maps"