googlemaps / google-maps-services-js

Node.js client library for Google Maps API Web Services
Apache License 2.0
2.91k stars 640 forks source link

InvalidValueError: unexpected property "travelMode" #195

Closed SachaG closed 6 years ago

SachaG commented 6 years ago

I'm getting the following error when I try to make a request while specifying the travelMode option:

(node:65354) UnhandledPromiseRejectionWarning: InvalidValueError: unexpected property "travelMode"
at /Users/sacha/Dev/zensroom/node_modules/@google/maps/lib/internal/validate.js:90:15
at /Users/sacha/Dev/zensroom/node_modules/@google/maps/lib/internal/validate.js:159:15
at Array.forEach (<anonymous>)
at Object.validator (/Users/sacha/Dev/zensroom/node_modules/@google/maps/lib/internal/validate.js:158:16)
at Object.distanceMatrix (/Users/sacha/Dev/zensroom/node_modules/@google/maps/lib/index.js:55:25)

Looking at the code, it seems like the proper options is not:

travelMode: 'WALKING'

As specified in the docs, but instead:

mode: 'walking'

This should probably be documented/corrected somewhere?

stephenmcd commented 6 years ago

You've mixed up the client-side JavaScript API with the server-side API that this library supports - https://developers.google.com/maps/documentation/distance-matrix/intro#optional-parameters

SachaG commented 6 years ago

Oh ok, my bad! That's pretty confusing though, also the documentation doesn't make it very easy to locate the right API docs.