Distance Matrix

Google Maps Distance Matrix

For AppInventor & Makeroid Apps


Description

This script will allow you to get the travel distance between two points using Google Maps Matrix Distance API.
It allows you to setup all GoogleMaps Trave parameters, like transport method or departure time.


How to use it

To use the script, you will need to setup a WebComponent in your AppInventor project, and disable SaveResponse checkbox and leave blank the URL
Then, in blocks screen, init a variable called base_url with the value https://scripts.makeroid.io/distance-matrix/ - (http://scripts.makeroid.io/distance-matrix/)
And then, you can setup parameters to that variable using the block join(Text) like ?distance-matrix to customize the script

Customization Parameters

With those params you can use this script, but continue reading if you want more customization. So, a basic usage example would be: http://scripts.makeroid.io/distance-matrix/?distance_matrix&origin&a_lat=42.8265457&a_lon=-8.6052464&destination&z_lat=42.8389455&z_lon=-8.5833596

You can join all of this parameters (except some of them that have already been already marked)

Handle response


Use it yourself

Use your own API Key

Add this parameter to use your own API Key: &custom_key=
eg.: https://scripts.makeroid.io/distance-matrix/?distance_matrix&custom_key=your_matrix_key

You can request one here:
Google Maps -> Distance Matrix API -> Google Developers Console

Source Code

SourceCode is avaliable on GitHub:
Distance Matrix


Docs

6 Likes

this is really gonna help me. thank u so much

1 Like

If you need help finding your coordinates

Use this website: GPS Coordinates


Without graphical interface:

https://scripts.makeroid.io/coordinates/?coordinates&location&country=your_country&province=your_state&city=your_city&street=your_street&need&longitude
and
https://scripts.makeroid.io/coordinates/?coordinates&location&country=your_country&province=your_state&city=your_city&street=your_street&need&latitude

Using GoogleMaps API



If you want Reverse Geocoding

https://scripts.makeroid.io/reversegeocoding/?reverse&lat=your_latitude&lng=your_longitude

Example:
https://scripts.makeroid.io/reversegeocoding/?reverse&lat=40.714224&lng=-73.961452

3 Likes

nice tutorial, is there an aia file so we can try it??

Thanks but the links do not load on page ( scripts.kodular.io redirected you too many times.).

Any progress with enabling the link?

Well…If you want to calculate distance between two places then I have something for you.

Or if you don’t want to use extension then:

2 Likes

The response includes the distance and duration between the specified origins and destinations.

I need the calculation of the distance and the duration of the route by car. not only the distance between two points. the script is perfect to do it, because otherwise I would have to do it directly with the google api

Then we have to wait for Kodular Staffs’ reply.

Can u share some aia? Coz some links are not working anymore.

Just curious, is there any chance that this script is still working? I tried out the links and none of them worked.

I don’t think so, sorry… I’ve tried to search for the PHP script to publish it, in case someone wanted to self-host it, but I think it’s just gone forever…
Though, that script was pretty much old, so knowing how Google APIs work, probably it would need some refactor to be back in place.

1 Like