Calculate distance between 2 cities

Hello,

I want to implement this functionality in my site, I uploaded the cities and now I have to choose the API to implement it.

Is there anyone free??

Could somebody help me with this isse??

Thank you in advance.

BR

Hi @Albar0,

Install the pipes Travel Distance. I dont know how many cities are here. If this do not work, I thinks that should use another Api System like Google Maps or Here Maps.

image

2 Likes

@dtellogaete

Did you try this before??

It doesn’t work as I tried.

Hi @Albar0,
I worked with API for get distance between two cities but using Here Maps (https://developer.here.com/) four year ago out of Tadabase.
What do you need to do?

Tadabase uses Google Maps Api

. You need the credentials.

I need to calculate the miles or km between to cities.

@Albar0
ok, I thinks that you can use the APIs, but you need to know programming and read the API documentation. I share the simple code in python using the HERE Api for get distance between two cities.

import herepy
from ast import literal_eval

app_id='insert id here'
app_code='insert code here'
routingApi = herepy.RoutingApi(app_id, app_code)

response = routingApi.car_route([-41.30598, -73.4529],
                            [-41.38933, -73.46485],
                            [herepy.RouteMode.car, herepy.RouteMode.fastest])




data=literal_eval(str(response))
#print(data)
data=literal_eval(str(data["response"].get("route")[0]))
data=literal_eval(str(data["leg"][0]))
distance=data["length"]/1000

print("distancia",distance,"km")