Google Maps Uncaught TypeError:无法读取Google Maps中未定义的属性"start_location" [英] google maps Uncaught TypeError: Cannot read property 'start_location' of undefined in google maps
本文介绍了Google Maps Uncaught TypeError:无法读取Google Maps中未定义的属性"start_location"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Google地图JS中有这个简单的函数,但遇到未捕获的typeerror
Hi I have this simple function in JS for google maps and I get uncaught typeerror
directionResult是Google路线响应对象,由其他函数传递给此函数.
directionResult is google directions response object which is passed by other function to this function.
var myRoute = directionResult.routes[0].legs[0];
var warnings = document.getElementById("warnings_panel");
for (var i=0;i<3;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];
}//
推荐答案
很难说出更多的信息,但是我会检查myRoute.steps数组是否至少包含三个元素.
Hard to tell without more information but I would check that the myRoute.steps array contains at least three elements.
这篇关于Google Maps Uncaught TypeError:无法读取Google Maps中未定义的属性"start_location"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文