0

I am trying to use the DistanceMatrixService from @react-google-maps/api. One of the required parameters is the 'travelMode'. However, when I tried setting 'travelMode' to 'DRIVING', it shows the following!

enter image description here

I tried doing travelMode: google.maps.TravelMode.DRIVING but it also throws a type error

TypeError: Cannot read properties of undefined (reading 'maps')

enter image description here

Here is a snippet of my code where I call the Distance Matrix Service.

snippet

James Z
  • 12,209
  • 10
  • 24
  • 44
nicole
  • 1
  • 1
  • Where's your code? – Lalit Fauzdar Apr 06 '22 at 05:35
  • Updated code snippet @LalitFauzdar. – nicole Apr 06 '22 at 05:47
  • You're facing Type issue as your screenshot and code snipped shows: `Type "Driving" is not assignable to Type "TravelMode"`. For this, check this typescript example on [Google docs](https://developers.google.com/maps/documentation/javascript/examples/distance-matrix#maps_distance_matrix-typescript). – Lalit Fauzdar Apr 06 '22 at 07:01
  • @LalitFauzdar I tried using the "google.maps.TravelMode.DRIVING" however I guess the 'window.google' does not exist. Any idea on how to work around this? – nicole Apr 06 '22 at 07:44

0 Answers0