Q:

Google Maps Api v3 Directions route not displaying

The problem is with the construction of routes.
The script is loaded into the header by using a script tag src: maps.googleapis.com/maps/api/js?sensor=false   
Error console:  Uncaught TypeError: Error is not a function main.js:19(google file)

obj route:
    
    Object {origin: I, destination: I, waypoints: Array[2], travelMode: "DRIVING", optimizeWaypoints: false}
    
    Code route:
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();
        }
    }
);

What could be the problem?

A:

I found the reason. In main.js set global function Error . I have a global class Error, responsible for the output of errors, etc. My class is overwritten this feature

