# Calculating Driving Distance between two waypoints

**URL:** <https://discourse.julialang.org/t/calculating-driving-distance-between-two-waypoints/32866>\
**Category:** General Usage\
**Created:** [January 2, 2020, 5:56am UTC](https://discourse.julialang.org/t/calculating-driving-distance-between-two-waypoints/32866 "2020-01-02T05:56:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dervis](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@Dervis](https://discourse.julialang.org/u/Dervis)\
**Post date:** [January 2, 2020, 5:56am UTC](https://discourse.julialang.org/t/calculating-driving-distance-between-two-waypoints/32866/1 "2020-01-02T05:56:35Z")

</div>

Dear all,

I wonder if there is any way to calculate driving distance and driving time between two waypoints? I have checked Googlemaps Distance Matrix API, but I couldn’t find any solid example that is used in Julia.

Any help would be appreciated!  
Thanks

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [January 2, 2020, 8:48am UTC](https://discourse.julialang.org/t/calculating-driving-distance-between-two-waypoints/32866/2 "2020-01-02T08:48:16Z")

</div>

There is [https://github.com/yeesian/GoogleMaps.jl](https://github.com/yeesian/GoogleMaps.jl) but it is slightly out of date, you might consider taking it as a starting point and making a PR if you get it to work.

---

<div class="post-metadata">

**Author:** ![Dervis](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@Dervis](https://discourse.julialang.org/u/Dervis)\
**Post date:** [January 2, 2020, 9:52am UTC](https://discourse.julialang.org/t/calculating-driving-distance-between-two-waypoints/32866/3 "2020-01-02T09:52:05Z")

</div>

Thank you for the response. I already checked it, not useful, I am using Julia 1.3.0, and it is not recognizing functions, etc written in this code. I found this: [https://github.com/ellisvalentiner/GoogleMaps.jl/blob/master/test/runtests.jl](https://github.com/ellisvalentiner/GoogleMaps.jl/blob/master/test/runtests.jl), however I dont know how to introduce my GoogleMaps\_API\_key into the code. Is there anyone knowing this? Replacing my API\_key with “GOOGLE\_MAPS\_KEY” in the fifth row doesn’t work.

Thank you

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [January 2, 2020, 9:55am UTC](https://discourse.julialang.org/t/calculating-driving-distance-between-two-waypoints/32866/4 "2020-01-02T09:55:47Z")

</div>

You need to set an environment variable, i.e. in Julia do `ENV["GOOGLE_MAPS_KEY"] = your_api_key` and then do `ENV["GOOGLE_MAPS_KEY"]` should return your api - this environment variable is what the package queries.

---

<div class="post-metadata">

**Author:** ![Dervis](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@Dervis](https://discourse.julialang.org/u/Dervis)\
**Post date:** [January 2, 2020, 5:30pm UTC](https://discourse.julialang.org/t/calculating-driving-distance-between-two-waypoints/32866/5 "2020-01-02T17:30:52Z")

</div>

Thank you for the response.

Unfortunately, I am having error saying:

UndefVarError: [[REDACTED]] not defined

Stacktrace:  
[1] top-level scope at In[6]:4

Does anyone know why? Is there anything wrong with my googlemaps key?  
Thanks

---

<div class="post-metadata">

**Author:** ![Pbellive](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pbellive/32/3604_2.png) [@Pbellive](https://discourse.julialang.org/u/Pbellive)\
**Post date:** [January 2, 2020, 5:50pm UTC](https://discourse.julialang.org/t/calculating-driving-distance-between-two-waypoints/32866/6 "2020-01-02T17:50:08Z")

</div>

Environment variables need to be strings. So if your API key is foo123, you need to do

```julia
ENV["GOOGLE_MAPS_KEY"] = "foo123"

```

and not

```julia
ENV["GOOGLE_MAPS_KEY"] = foo123

```

If you do the latter, julia looks for a variable called `foo123`. Also, if the error message you’ve posted above contains your actual API key, you might want to delete that.
