【问题标题】:Why this polyline is drawn wrong?为什么这条折线画错了?
【发布时间】:2013-06-09 21:46:02
【问题描述】:

有人知道为什么这条特定的折线画错了吗? 通常一切都很好,但是对于这次旅行,我现在不再有想法了! 测试地点:http://junkvibration.com/test/walk/test.htm

感谢您的帮助!

这个例子我的路点是:

waypoints: [{location:"Lucern",stopover:false},{location:"Paris",stopover:false},
{location:"Madrid",stopover:false},{location:"Granada",stopover:false},
{location:"Barcelona",stopover:false},{location:"Monaco",stopover:false},
{location:"Rom",stopover:false}],
optimizeWaypoints: false,
travelMode: google.maps.DirectionsTravelMode.WALKING };

【问题讨论】:

  • 为什么要为 5,609 公里的行程指定步行路线?在没有法律警告的情况下显示步行方向是违反使用条款的。如果我更改为行车路线,我不会获得路线 (ZERO_RESULTS)。如果我把所有的航点都设为 {stopover:true} 那么它就可以了。

标签: google-maps google-maps-api-3 map-directions google-polyline


【解决方案1】:

对我来说,这看起来像是 DirectionsService 中的一个错误。

如果我把所有的航路点都设为 {stopover:true} 那么它就可以了。

function calcRoute() {
  var request = {
    origin: "Bad Aussee",
    destination: "Rottenmann",
    waypoints: [{
      location:"Lucern",
      stopover:true
    },{
      location:"Paris",
      stopover:true
    },{
      location:"Madrid",
      stopover:true
    },{
      location:"Granada",
      stopover:true
    },{
      location:"Barcelona",
      stopover:true
    },{
      location:"Monaco",
      stopover:true
    },{
      location:"Rom",
      stopover:true
    }],
    optimizeWaypoints: false,
    travelMode: google.maps.DirectionsTravelMode.DRIVING
  };

  directionsService.route(request, function(response, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsDisplay.setDirections(response);
    } else {
      alert("Directions request failed: "+status);
    }
  });
}

working example - stopover:true

not working (ZERO_RESULTS) - stopover:false, same request as above otherwise

example tries the same request first with stopover:false (fails), then with stopover:true (succeeds)

walking directions (UNKNOWN_ERROR with stopover:true, weird path with stopover:false)

walking directions using multiple requests to the DirectionsService - 更好,但似乎想让我从摩纳哥游到罗马...

【讨论】:

  • 感谢您的回答,但“stopover:true”仅在驾驶模式下有帮助。在 WALKING 模式下不显示路线!那么,只有谷歌可以提供帮助吗? (此地图示例显示了一个虚拟地图 - 如圣詹姆斯之路)
  • 如果它真的应该是一条步行路线,那么我可以看一下,但我记得有一个错误,因为方向太复杂而无法在您的面板中显示没有显示,但你需要显示最后我查看了我们的条款。但无论如何,我认为这是 Google Maps API Directions 服务中的一个错误,应该有人在问题跟踪器中打开一个问题。
  • 谢谢,这对我帮助很大。我在问题跟踪器中报告了这个错误
  • 你在哪里报告了这个错误?你能提供一个链接吗?我在Google Maps API issue tracker 中没有看到它。
猜你喜欢
  • 1970-01-01
  • 2019-12-12
  • 1970-01-01
  • 2023-03-29
  • 1970-01-01
  • 1970-01-01
  • 2017-12-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多