Google Maps directionsService.route抛出javascript错误

Google Maps directionsService.route抛出javascript错误,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,例如,当“路由”由于不存在的地址而失败时,它会在控制台中抛出一个javascript错误。我真的不喜欢那样。它不应该友好地返回“未找到”吗?我一直在看文档,但找不到任何关于如何避免这种情况的答案。我真的需要将它封装在try/catch中吗 directionsService.route(request, function(response, status) { if (status == 'OK') { directionsRenderer.setDirections(respons

例如,当“路由”由于不存在的地址而失败时,它会在控制台中抛出一个javascript错误。我真的不喜欢那样。它不应该友好地返回“未找到”吗?我一直在看文档,但找不到任何关于如何避免这种情况的答案。我真的需要将它封装在try/catch中吗

directionsService.route(request, function(response, status) {
  if (status == 'OK') {
    directionsRenderer.setDirections(response);
  }
});
这在我们的公共问题追踪中得到了报道。您可以启动它以接收有关此问题的公开报告

同时,您可以先清除控制台以删除错误,然后记录方向服务响应的状态。下面是实现以下代码段的示例

  directionsService.route(
      {
        origin: {query: Your_ORIGIN},
        destination: {query: YOUR_DESTINATION},
        travelMode: 'DRIVING'
      },
      function(response, status) {
        if (status === 'OK') {
          directionsRenderer.setDirections(response);
        } else {
          console.clear();
          console.log('Directions request failed due to ' + status);
        }
      });

它在控制台中抛出了什么javascript错误?请提供一份说明您的问题的报告。