[英]Google Maps waypoints not working
因此,我不知道此代码有什么问题,需要帮助。
我希望用户输入起点,航点和终点地址。
var start = document.getElementById('start').value;
var way = document.getElementById('way').value;
var end = document.getElementById('end').value;
var request =
{
origin: start,
destination: end,
waypoints: way,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
................................................... ............................
<strong>Start:</strong>
<input id="start" type="text" ></input>
<strong>Waypoint:</strong>
<input id="way" type="text" ></input>
<strong>End:</strong>
<input id="end" type="text" ></input>
似乎不明白我在哪里弄错了,并在此先感谢您的解释。
航点是DirectionsWaypoint对象的数组。 这些对象包含一个LatLng对象或地址字符串以及一个Boolean stopover属性。
尝试这个:
var waypoints = [];
waypoints.push({
location:document.getElementById('way').value,
stopover:true // true by default. Technically this property is optional.
});
这是使用航点的Google示例应用 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.