DistanceMatrixService

The DistanceMatrixService component wraps google.maps.DistanceMatrixService and calls getDistanceMatrix whenever options changes.

Storybook

Open the DistanceMatrixService story

Props

PropTypeDescription
optionsgoogle.maps.DistanceMatrixRequestDistance Matrix request.
callback(response, status) => voidReceives the response and status.
onLoad(service: google.maps.DistanceMatrixService) => voidCalled after service creation.
onUnmount(service: google.maps.DistanceMatrixService) => voidCalled before teardown.

Usage

<DistanceMatrixService
  options={{ origins, destinations, travelMode: 'DRIVING' }}
  callback={(response, status) => console.log(status, response)}
/>
svelte