Google Maps API Terms of Service have a restriction regarding route guidance. Particularly paragraph 10.4.c (iii) states
No navigation. You will not use the Service or Content for or in connection with (a) real-time navigation or route guidance; or (b) automatic or autonomous vehicle control.
Additionally, you have to pay attention to other restrictions that might be violated in your use case
Paragraph 10.1 a
No access to APIs or Content except through the Service. You will not access the Maps API(s) or the Content except through the Service. For example, you must not access map tiles or imagery through interfaces or channels (including undocumented Google interfaces) other than the Maps API(s).
Paragraph 10.5 d
No caching or storage. You will not pre-fetch, cache, index, or store any Content to be used outside the Service, except that you may store limited amounts of Content solely for the purpose of improving the performance of your Maps API Implementation due to network latency (and not for the purpose of preventing Google from accurately tracking usage), and only if such storage: is temporary (and in no event more than 30 calendar days);
is secure; does not manipulate or aggregate any part of the Content or Service; and does not modify attribution in any way.
https://developers.google.com/maps/terms#10-license-restrictions
So Google discourage the thing that you try to implement.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…