[英]Can't seem to find unexpected identifier
对于一个大学项目,我正在使用 Django 框架开发一个应用程序,该应用程序允许用户找到附近的餐馆和其他场所,并通过 Google 路线服务获取到他们的路线。
我刚刚将服务概述代码示例中的calculateAndDisplayRoute
函数复制到我的模板中,并且不断收到意外的标识符错误,但我没有发现问题。
请记住,我对 JavaScript 还很陌生,所以我可能会在这里忽略一些明显的东西。 这是代码片段:
function calculateAndDisplayRoute(directionsService, directionsDisplay) {
directionsService.route({
origin: new.google.maps.LatLng(43.0186, -7.5813),
destination: new.google.maps.LatLng(43.0157, -7.5495),
travelMode: travel_mode
}, function(response, status) {
if (status === 'OK') {
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}
我在 'origin: ...' 行收到错误。 出于测试目的,源值和目标值是固定的。 这是完整的脚本: https : //pastebin.com/sbNtVLYk
提前致谢。
编辑:完整模板代码: https : //pastebin.com/8rhTGPXA
new
是 JavaScript 中的保留作品,请参阅此处的说明: https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/new
所以无效的行是
origin: new.google.maps.LatLng(43.0186, -7.5813),
destination: new.google.maps.LatLng(43.0157, -7.5495),
stackoverflow 上高亮显示的代码也突出显示了这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.