谷歌地图 API 错误:属性<航点>::中的错误
google map api Error: Error in property <waypoints>:
我正在尝试在谷歌地图 api 上设置一些航点,但得到以下错误。我知道这与设置对象有关,但我似乎无法正确处理。我也找不到任何确切的文章。
Error: Error in property <waypoints>: (Invalid value: Ballybricken, Waterford, Ireland,The Glen, Waterford (Error in element at position 0: (Unknown property <0>)))
我的代码
var waypts = ["Ballybricken, Waterford, Ireland", "The Glen, Waterford"];
drawPolyline('Waterford Regional Hospital', 'Hillview, Waterford, Ireland', waypts);
function drawPolyline(source,destination,waypoints){
// show route between the points
directionsService = new google.maps.DirectionsService();
directionsDisplay = new google.maps.DirectionsRenderer(
{
suppressMarkers: true,
suppressInfoWindows: true,
polylineOptions: { strokeColor: '#000000', strokeOpacity: 0.5 }
});
directionsDisplay.setMap(map);
var request = {
origin:source,
destination:destination,
waypoints:waypoints,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status)
{
if (status == google.maps.DirectionsStatus.OK)
{
directionsDisplay.setDirections(response);
}
});
}
航点不是地址或 latLng,它是一个由(必需的)location
-member 和一个(可选)stopover
-member 组成的对象,所以你的数组应该看起来像这样:
var waypts = [{location:"Ballybricken"},
{location:"Waterford"},
{location:"Ireland"},
{location:"The Glen"},
{location:"Waterford"}];
相关文章:
- 淡入左图像滚动航点
- 谷歌地图 API 错误:属性<航点>::中的错误
- JQuery 航点协助
- Jquery - 航点 - 动画导航
- 到达航点后不重复该功能
- 更改粘性标头航点或偏移的位置
- 使用 jQuery 航点滚动时跳转标题
- 仅当具有相同类的元素的中间使用 jQuery 航点到达视口时,才淡入具有相同类的元素
- 使用航点切换类
- jQuery 航点在元素滚动到视图中时添加类
- 检测航点是否可到达
- 谷歌地图航点超过8个问题
- 使用航点 jquery(动画)平滑滚动
- 航点JS和锚链接问题
- 奇怪的错误:每次点击代码都会执行多次
- 为什么我不能摧毁()这些航点
- 如何将信息框添加到必应地图中的航点
- 使用谷歌方向 API 问题绘制超过 8 个航点的路线图
- 如何使用航点无限滚动.js
- HTML5 Canvas游戏有错误,点击时第一个拼图块会变成不同的块