2017-07-27 52 views
-1

我一直在使用Google Directions API。我的JavaScript代碼可以在一兩天內正常工作,但是晚一天晚上它不工作。在FF控制檯:Google Directions,bug in common.js?

TypeError: b is undefined[Learn More] common.js:49:155

FWIW,這是common.js線49(不是我的代碼!):

e;_.sb(d);window.gm_authFailure&&window.gm_authFailure()}El();c(b)})})};.cn=function(a,b){a.b();return function(){var c=this,d=arguments;a.f(function(a){a&&b.apply(c,d)})}};dn=function(a,b,c,d,e,f){this.b=new Km;this.b.setUrl(c.substring(0,1024));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=function(a){Dl=!0;0!=a.getStatus()||.Aj(a,2)||($m(),.P(a,3)&&.sb(_.P(a,3)));El()};

我敢肯定錯誤在我的客戶端與此相關的呼叫側應用:

directionsService.route(myRequest,myCallback);

這是一個谷歌方法,要求谷歌從一個地理點到另一個地點的方向。

這裏是我的代碼:https://pastebin.com/AtcFQ9tZ

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); 
} 
+1

請在您的問題中包含相關的代碼。你可以閱讀更多關於[如何在這裏提問](https://stackoverflow.com/help/how-to-ask):) – 0mpurdy

+0

common.js第49行是相關的代碼。你還想要什麼? – Drakken

+1

我的意思是編輯你的問題實際上包括你的代碼 - 可能是包含'directionsService.route(myRequest,myCallback); '和directionsService.route'方法本身至少有 – 0mpurdy

回答

0

好吧,我發現我自己的代碼的bug。這是一個未定義的回調(ost.showCost而不是本地showCost)。