You are getting this error because this feature can't be used for future usage. According to the developer docs for Distance Matrix:
This product or feature is in Legacy status and cannot be enabled for new usage.