Javascript Google方向,common.js中的bug?
我已经使用GoogleDirections api好几天了。我的javascript代码在一两天内运行良好,但有一天晚上很晚它就不工作了。在FF控制台中: TypeError:b未定义[了解更多信息]常见。js:49:155 FWIW,这是common.js第49行(不是我的代码!): e、 !。sb(d);window.gm_authFailure&&window.gm_authFailure()}El();c(b)};。cn=函数(a,b){a.b();返回函数(){var c=this,d=arguments;a.f(函数(a){a&&b.apply(c,d)});dn=函数(a,b,c,d,e,f){this.b=新Km;this.b.setUrl(c.substring(01024));f&&(this.b.data[8]=f);d?this.b.data[1]=d:e&(this.b.data[2]=e);this.b.data[4]=0;this.b.data[5]=1;this.l=a;this.j=b};en=函数(a){Dl=!0;0!=a.getStatus()|| |.Aj(a,2)| |($m(),.P(a,3)&.sb(u.P(a,3));El() 我很确定该错误与我客户端应用程序中的此调用有关: 路由(myRequest,myCallback) 这是一种谷歌方法,它向谷歌询问从一个地理点到另一个地理点的方向 这是我的密码:Javascript Google方向,common.js中的bug?,javascript,google-maps,Javascript,Google Maps,我已经使用GoogleDirections api好几天了。我的javascript代码在一两天内运行良好,但有一天晚上很晚它就不工作了。在FF控制台中: TypeError:b未定义[了解更多信息]常见。js:49:155 FWIW,这是common.js第49行(不是我的代码!): e、 !。sb(d);window.gm_authFailure&&window.gm_authFailure()}El();c(b)};。cn=函数(a,b){a.b();返回函数(){var c=this,d
嗯,我在自己的代码中发现了这个bug。这是一个未定义的回调(ost.showCost而不是本地showCost) 请在您的问题中包含相关代码。您可以阅读更多关于:)common.js第49行是相关代码。你还想要什么?我的意思是编辑你的问题以实际包含你的代码-可能是包含
directionsService.route(myRequest,myCallback)的方法
和directionsService.route
方法本身,至少您必须向Google开发人员询问directionsService.route()的源代码。以下是文档:我的错误我不知道那不是你的错误:如果可能的话,我想从我以前的评论中选择另一个选项:包含directionsService.route(myRequest,myCallback)的方法代码>
ost.setPickupCharge = function(position)
{
var p = ost.pickup;
p.lat = position.coords.latitude;
p.lng = position.coords.longitude; /* alert("lat: " + lat + "\nlng: " + lng); */
var request = {
origin: '45 East University Avenue, Champaign, IL',
destination: new google.maps.LatLng(p.lat,p.lng),
provideRouteAlternatives: false,
travelMode: 'DRIVING'
}
function showCost(result, status) {
if (status != 'OK') { alert(status) }
else {
var route = result.routes[0];
var dists = route.legs.map(function(leg) { return leg.distance.value }); p.miles = 0.00062137 * A.sum(dists);
var times = route.legs.map(function(leg) { return leg.duration.value }); p.minutes = A.sum(times) / 60;
p.charge = .6 * p.miles + .15 * p.minutes;
alert("pickup charge = $" + p.charge);
ost.showRideButtons();
}
}
directionsService.route(request,ost.showCost);
}