问题在于路线的建设 使用脚本标记src将脚本加载到标头中:maps.googleapis.com/maps/api/js?sensor=false
Error console: Uncaught TypeError: Error is not a function main.js:19(google file)
obj路线:
Object {origin: I, destination: I, waypoints: Array[2], travelMode: "DRIVING", optimizeWaypoints: false}代码路线:
IMaps.getDirectionsService().route(obj,
function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
var count = result.routes[0].legs.length;
var sumDist = 0;
for (var k = 0; k < count; k++) {
sumDist += result.routes[0].legs[k].distance.value;
}
sumDist = (sumDist > 1000) ? ((sumDist / 1000).toFixed(2) + ' км.') : sumDist + ' м.';
$('.width-route').html(sumDist);
MAPS.getDirectionsRenderer().setDirections(result);
IMaps.showMap();
} else {
alert('Error');
document.location.reload();
}
}
);
可能是什么问题?
答案 0 :(得分:0)
我找到了原因。在main.js中设置全局函数Error。我有一个全局类Error,负责输出错误等。我的类被覆盖了这个功能