Google Maps Distance Matrix Nodejs timeout
Asked Answered
R

1

7

We have an application that depends on Google maps distance matrix API to calculate distance and time between two points. It's a nodejs application. We have been using this Google Maps Node.js Client

The application has been working okay. Now it times out. We have accepted the new pricing and terms of service that got into effect since July 16, added a billing account as well as generate a new key. We thought that could be the case but we are still getting a timeout error.

Our code is as follows:

const googleMaps = require("@google/maps");

let mapsClient = googleMaps.createClient({ 
    key: process.env.GOOGLE_MAPS_KEY, 
    Promise: Promise 
});

mapsClient.distanceMatrix({
    origins: fromLat + ',' + fromLng,
    destinations: toLat + ',' + toLng,
    mode: 'driving'
}).asPromise().then(res => {
    // Do something in case of success
}).catch(err => {
    // Do something else in case of error
    console.log('MAPS ERROR', err); // Prints out a timeout
});

I cannot figure out what we are doing wrong. Logging the error on catch prints out timeout. Please help.

Ronen answered 1/8, 2018 at 20:33 Comment(3)
I'm facing the same problem here. did you find any solution for this? if yes, please share your findings. :)Hazem
I'm having the same issue. Have anyone found a solution for it?Bedraggled
I'm having the same issue. Have anyone found a solution for it?Diadelphous
D
0

try this

Go to query editor -right click your web data source - Advanced Editor. This will give you access to M code behind it. You need to specify "timeout" interval in there manually. >>[timeout=#duration(0,0,30,0)])) This is a TimeSpan like parameter, with the values representing Days, Hours, Minutes, Seconds.

Disembogue answered 29/9, 2022 at 17:46 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.