- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最近,在我们的应用程序的起点和目的地位置之间使用带有“航点”的 DirectionsService 时,我们一直在返回这些在视觉上没有意义的“之字形”路线。
看起来,一切都进行得很好,但在第 7 个航点之后的某个地方,该路线以戏剧性的之字形返回到较早的航点,然后似乎试图将自己纠正回正确的路径。
我附上了一张图片来展示我想说的话,并用红色指出事情出错的地方。此外,我还包含了下面的示例代码,并在此处发布了该问题的工作演示:
http://dev.anytraq.com:8080/test.html (工作版本)
我想知道这里是否有人遇到过这样的问题,或者可以了解可能发生的事情吗?正如您在下面看到的,代码非常简单......基本上我们只是定义了一个起点和终点 LatLng 对象,以及它们之间的 8 个航点,然后将其发送到 DirectionsService。
我很感激任何和所有可能想到的建议,我完全被难住了。
<!DOCTYPE html>
<html>
<head>
<title>ZigZagged Directions Example</title>
<meta charset="UTF-8">
<style type="text/css">
html, body, #map_canvas {
margin: 0;
padding: 0;
height: 100%;
}
</style>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var map;
function initialize() {
// map options
var myOptions = {
zoom: 8,
center: new google.maps.LatLng(-34.397, 150.644),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
// the map
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
// directions service
directionsService = new google.maps.DirectionsService();
// Define our origin position, the start of our trip.
originPosition = new google.maps.LatLng('37.66258', '-121.87058');
// Define 8 waypoints to place between the origin and the destination
waypoint1 = new google.maps.LatLng('37.65638', '-121.87750');
waypoint2 = new google.maps.LatLng('37.64333', '-121.88174');
waypoint3 = new google.maps.LatLng('37.63676', '-121.88447');
waypoint4 = new google.maps.LatLng('37.60746', '-121.87343');
waypoint5 = new google.maps.LatLng('37.57868', '-121.87702');
waypoint6 = new google.maps.LatLng('37.56368', '-121.90382');
waypoint7 = new google.maps.LatLng('37.54175', '-121.92334');
waypoint8 = new google.maps.LatLng('37.51806', '-121.94201');
// push the waypoints defined above into an array
wayPointArray = new Array();
wayPointArray.push({location: waypoint1, stopover: false});
wayPointArray.push({location: waypoint2, stopover: false});
wayPointArray.push({location: waypoint3, stopover: false});
wayPointArray.push({location: waypoint4, stopover: false});
wayPointArray.push({location: waypoint5, stopover: false});
wayPointArray.push({location: waypoint6, stopover: false});
wayPointArray.push({location: waypoint7, stopover: false});
wayPointArray.push({location: waypoint8 , stopover: false});
// define our definition position, the last stop of our trip
destinationPosition = new google.maps.LatLng('37.50162', '-121.93034');
var request = {
origin: originPosition,
destination: destinationPosition,
waypoints: wayPointArray,
travelMode: google.maps.DirectionsTravelMode.DRIVING,
unitSystem: google.maps.DirectionsUnitSystem.METRIC,
optimizeWaypoints: false
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
var polyOpts = {
strokeOpacity: 1.0,
strokeColor: '#0000FF',
strokeWeight: 2
}
var directionsDisplayOptions = {
suppressMarkers: false,
suppressInfoWindows: false,
preserveViewport: false,
polylineOptions: polyOpts
};
directionsRenderer = new google.maps.DirectionsRenderer(directionsDisplayOptions);
directionsRenderer.setMap(map);
directionsRenderer.setDirections(response);
} else {
console.info('could not get route');
console.info(response);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map_canvas"></div>
</body>
</html>
最佳答案
这是渲染中的一个错误。
在“合并到 I-680”之后在 map 上绘制的线由此编码字符串给出,该字符串出现在来自路线服务的 JSON 响应中:
ylvdFjw|fVMJw@x@[Ha@FUGYOKSEYCYB[F[HOTUXMf@QRGxDoAlBIrBDpBDt@@@?p@?nAArCQlDW`BWjCy@`CwArKyHxGcDpA_@vA[rAWtAOxAKpAEdABhBGpEAvAAfCKnGQzDm@lGkCfGiC~CoAhb@mPrDuA~`@oLn@Q~EgBr@Up@MpAKnBGb@?nBLnAX`AVx@Xt@Z?@z@\\HDfBz@rChAtCj@jDHpCU~Cw@~As@jAw@x@m@bDcCbDeCh@a@fAg@FEf@SBA`Bs@jAM`@Cn@CfB?hBPbB\\`CdA`@NJD^NlAb@bM`GlW~JfHzC|D`CpD~DlAxAl@t@bFvGbApAl@hAVj@Pf@d@rAn@hCjFnUh@|ANd@rCfFxEtIvA|BrNd[zZpr@xAhCfEdFlHxJRVhA`B`@~@t@hBh@`BjAlF`BbIpA~EnA~CpA|B~@lA|A~ArDvCzDzCfClBDB`DtBx@h@fHnDzB|@~B`AjH`DzEnBdAb@jB`@dCRrDJtADnBLpCr@dAd@l@Vz@d@vA`A`@\\d@b@vDlErHzIj@p@LPRRf@n@lB`CjBfCzApCVb@jCdGtClHjCjGjCpGjAxCBFtJbUFNDLx@zBnArC~CtHnCpF`@t@P\\LTP^|@~A\\j@hChElB|CrAxBb@h@t@x@h@j@lA|@~@d@vBt@rCh@lBHxAAdEc@nAa@jAo@~@k@pA}@vFuFvDqDdF}DrFcDlB_AhJeEbEyBVMlAo@rJsEhAm@~EiCtD{AlHeD~GkDxBwAVOZSz@i@TShCwBpJiKfHqI
关于google-maps - 使用航点时,通过 DirectionsRenderer "zig-zags"渲染的路线返回上一个航点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11480987/
好的,这里是 splay 算法,如果你想检查的话。 这是我的 splay 函数: template void SplayTree::Do_Splay(SplayNODE *temp) //tem
我已经找到了以下完美的 CSS 片段,它在这个 link 处创建了 zip zag 边框. .h-zigzag { background: linear-gradient(-1
我正在尝试制作一些 CSS 代码,以便在我的 BODY 标签的左侧和右侧有垂直的锯齿线。 我希望它看起来像一张票……在页面的左右两边从上到下是这样的:https://roalddahl.fandom.
我目前正在学习 DP,我正在通过 topsider 教程学习,并试图解决问题 ZigZag sequence理解并知道解决方案与计算最长递增子序列的长度非常相似。我编写了一个简单的 C++ DP 解决
我有以下数组: a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] 我将它用于一些像这样的视觉内容: 1 2 3 4 5 6 7 8 9 10
我从早上就开始摸不着头脑,我什至没有达到看起来像给定模式的东西。感谢任何数量的帮助。提前致谢! 这不是我的家庭作业 编辑1:谢谢大家!我终于找到了解决方案。 `#include void main
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 问题必须表现出对正在解决的问题的最低限度的理解。告诉我们您尝试过的方法、为什么不起作用以及它应该 起作
I have been given a string and number of rows n. Print the string formed by concatenating n rows whe
任何人都可以帮助我理解 http://www.topcoder.com/stat?c=problem_statement&pm=1259&rd=4493 中提到的问题的解决方案背后的核心逻辑吗? 之字
最近,在我们的应用程序的起点和目的地位置之间使用带有“航点”的 DirectionsService 时,我们一直在返回这些在视觉上没有意义的“之字形”路线。 看起来,一切都进行得很好,但在第 7 个航
我需要在日期选择器中使用日期,就像下面的模式一样,在 Javascript Datepicker 中使用 Zig-Zag 流 2014-11-10 - 2014-11-152014-11-16 - 2
我不太明白为什么 splay 树数据结构中的旋转不仅要考虑评级节点的父节点,还要考虑祖父节点(zig-zag 和 zig-zig 操作)。为什么以下内容不起作用: 例如,当我们向树中插入一个新节点时,
我不太明白为什么 splay 树数据结构中的旋转不仅要考虑评级节点的父节点,还要考虑祖父节点(zig-zag 和 zig-zig 操作)。为什么以下内容不起作用: 例如,当我们向树中插入一个新节点时,
这道题可以只用一个 dp 数组来完成吗?这是来自 topcoder ( http://community.topcoder.com/stat?c=problem_statement&pm=1259&r
我是一名优秀的程序员,十分优秀!