# Google maps distance matrix

**URL:** <https://community.glideapps.com/t/google-maps-distance-matrix/42198>\
**Category:** Ask for Help\
**Created:** [May 20, 2022, 9:36am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198 "2022-05-20T09:36:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [May 20, 2022, 9:36am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/1 "2022-05-20T09:36:02Z")

</div>

Greetings to all.  
I was experimenting with a new feature for my web app that would show me the actual mileage and travel time, from an origin point to a destination point.

The origin of the example is:

[https://maps.googleapis.com/maps/api/distancematrix/json?destinations=Fumone&origins=Anzio&units=metric&key=AIzaSyCLxnSvhGjjVPntRcZPhRDTt4SDZZ5m\_PQ](https://maps.googleapis.com/maps/api/distancematrix/json?destinations=Fumone&origins=Anzio&units=metric&key=AIzaSyCLxnSvhGjjVPntRcZPhRDTt4SDZZ5m_PQ)

I then inserted the Google URL into a column with a template (see image), taking the start and end path data from two other columns.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/9/a93a65dfa6adefb1e8edefe226953f45f1b7b89d.png)

Finally, I used a Fetch column, having the template URL as its origin and the JQ Query for the distance described below:  
.rows.elements.distance.text

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/4/c4aff38cec316b16d7a43672039a5643004c9687.png)

The problem is this: if I try it in the plugin-\>TransformJson section and run the query with the JSON, everything works. However, if I run it from a Fetch column created for this purpose, it does nothing.

Can anyone explain the arcane?

@Jeff_Hager @Robert_Petitto @ThinhDinh @Darren_Murphy

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 20, 2022, 9:50am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/2 "2022-05-20T09:50:58Z")

</div>

So your fetch JSON with the JQ Query returns nothing?

---

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [May 20, 2022, 9:52am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/3 "2022-05-20T09:52:24Z")

</div>

Nothing, all empty ☹  
I have included the link just so you can try it

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 20, 2022, 9:55am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/4 "2022-05-20T09:55:20Z")

</div>

I’m not getting anything even without the query, so I assume this is a CORS problem. Sorry I don’t have a solution for this, if you’re using user-specific columns to feed the destination and origin.

If they are basic columns instead, I think you can use a HTTP call in Integromat/Make to write the distance and other things back to Glide.

---

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [May 20, 2022, 10:24am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/5 "2022-05-20T10:24:52Z")

</div>

Curious, it gives me the result I was looking for

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/b/0b331e48d980da88abc1e227bb29543bbbc3550f.png)

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 20, 2022, 12:51pm UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/6 "2022-05-20T12:51:22Z")

</div>

It means no JSON was returned in the app, so there’s nothing for the JQ Query code to work on.

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [May 20, 2022, 2:32pm UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/7 "2022-05-20T14:32:38Z")

</div>

> [@profxeni](#):
>
> Curious, it gives me the result I was looking for

Hola!,

I tested several times and really something wrong happens here.

Looks like Glide has a problem with that API or with that Google’s server.

If you test by using this Glide’s tool [Fetch JSON column | Glide](https://www.glideapps.com/plugins/fetch), you won’t receive any reply/data

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/8/98b637c1570aceaf3b1c5fe52ff18d46333018d5.jpeg)

It’s very weird!

Saludos!

---

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [May 20, 2022, 5:18pm UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/8 "2022-05-20T17:18:53Z")

</div>

Thank you for your help. In the end, I opted for a script run directly from Google Sheets, also adding a cache that refreshes every 6 hours, to help me with code calls to Google Maps. In conclusion, one way or the other, the solution is always found!  
[Here](https://www.labnol.org/google-maps-sheets-200817) I have found all the solutions that may also be of use to others within this community.

---

<div class="post-metadata">

**Author:** ![ShantanuIyengar](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/shantanuiyengar/32/35546_2.png) [@ShantanuIyengar](https://community.glideapps.com/u/ShantanuIyengar)\
**Post date:** [May 20, 2022, 5:32pm UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/9 "2022-05-20T17:32:45Z")

</div>

> [@profxeni](#):
>
> [https://maps.googleapis.com/maps/api/distancematrix/json?destinations=Fumone&origins=Anzio&units=metric&key=AIzaSyCLxnSvhGjjVPntRcZPhRDTt4SDZZ5m\_PQ](https://maps.googleapis.com/maps/api/distancematrix/json?destinations=Fumone&origins=Anzio&units=metric&key=AIzaSyCLxnSvhGjjVPntRcZPhRDTt4SDZZ5m_PQ)

You could also try the data → fetch json in which you use this url  
in JQuery

You could write  
.rows[0].elements[0].distance.text

I think you were missing the 0 element number

---

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [May 20, 2022, 5:37pm UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/10 "2022-05-20T17:37:26Z")

</div>

> [@ShantanuIyengar](#):
>
> .rows[0].elements[0].distance.text

It doesn’t work that way either ☹  
I thank you anyway. 🙃

---

<div class="post-metadata">

**Author:** ![SantiagoPerez](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/santiagoperez/32/16807_2.png) [@SantiagoPerez](https://community.glideapps.com/u/SantiagoPerez)\
**Post date:** [May 20, 2022, 7:50pm UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/11 "2022-05-20T19:50:08Z")

</div>

You have to create all the functionality either in Replt or Github and add your API key there. Then use an Experimental column to do it.

The way you’re doing it will not work because of CORS issues.

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [May 21, 2022, 6:35pm UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/12 "2022-05-21T18:35:11Z")

</div>

> [@SantiagoPerez](#):
>
> The way you’re doing, it will not work because of CORS issues.

right!

Here the confirmation…

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/6/a6009085cb55192244cae1568537b83f7ff924d4.png)

---

<div class="post-metadata">

**Author:** ![profxeni](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/profxeni/32/24656_2.png) [@profxeni](https://community.glideapps.com/u/profxeni)\
**Post date:** [May 21, 2022, 7:10pm UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/13 "2022-05-21T19:10:24Z")

</div>

Thank you very much, I appreciate the help!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 21, 2022, 11:45pm UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/14 "2022-05-21T23:45:46Z")

</div>

Great catch. Many API links are not usable in the fetch column because of the same issue.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 22, 2022, 12:00am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/15 "2022-05-22T00:00:16Z")

</div>

I found the solution guys! @profxeni @gvalero @Robert_Petitto

Just append [https://corsanywhere.herokuapp.com/](https://corsanywhere.herokuapp.com/) to your URL.

For example:

`https://corsanywhere.herokuapp.com/https://maps.googleapis.com/maps/api/distancematrix/json?destinations=Fumone&origins=Anzio&units=metric&key=AIzaSyCLxnSvhGjjVPntRcZPhRDTt4SDZZ5m_PQ`

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/f/0fa7281db5612b809d26baf4ff1dfab092ff8fff.png)

Source:

> **[GitHub - Rob--W/cors-anywhere: CORS Anywhere is a NodeJS reverse proxy which...](https://github.com/Rob--W/cors-anywhere)**
>
> CORS Anywhere is a NodeJS reverse proxy which adds CORS headers to the proxied request. - GitHub - Rob--W/cors-anywhere: CORS Anywhere is a NodeJS reverse proxy which adds CORS headers to the proxi...

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 22, 2022, 12:11am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/16 "2022-05-22T00:11:46Z")

</div>

Just to make sure this is not a mistake, you’re showing your Google Maps API key @profxeni . Do you want us to remove it?

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [May 22, 2022, 1:16am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/17 "2022-05-22T01:16:48Z")

</div>

Great find @ThinhDinh

Does this work with Payhere then?

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [May 22, 2022, 1:41am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/18 "2022-05-22T01:41:46Z")

</div>

Thanks for the tip.

I tested like 10 Cors proxies and none worked for me 🤬 but happy to see it works and can be used.

Saludos Thinh!

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 22, 2022, 2:39am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/19 "2022-05-22T02:39:07Z")

</div>

![760a9d79daa6f601b531fc1716c88402ad205cbf](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/4/64b6939ed7c04076e104f3f87104b2c59e1ed482.jpeg)

```auto
https://corsanywhere.herokuapp.com/https://api.payhere.co/api/v1/subscriptions?page=1&per_page=50&access_token=[your_token]

```

Working for me.

Pass your token in access\_token, I was fetching all subscriptions in an account.

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [May 22, 2022, 4:21am UTC](https://community.glideapps.com/t/google-maps-distance-matrix/42198/20 "2022-05-22T04:21:35Z")

</div>

Nice!

[Next page](https://community.glideapps.com/t/google-maps-distance-matrix/42198.md?page=2)
