Isochrone api through google search bar

i’m quite new to programming and my first mission is to use ORS api (isochrone). I decided to use the google maps api for geocoding and maps, but now, I would like that when I enter an address in the google search bar, the ors api also draws an isochrone on the adress I inputed. so i looked at documentation and as a beginner i didn’t understand everything, here is the call i wanna make but i want to input the location by adress name like paris or london or my mom’s place :

const body = '{"locations":[[2.349014,48.864716],[2.349014,48.864716]],"range":[900,600,300],"attributes":["total_pop"],"range_type":"time","area_units":"m","units":"m"}';

If you guys could help me it would be wonderful !
thanks a lot

Hey,

I’m rather confused by your statements about the google maps api and the google search bar and the ors api, but I can answer

This will require you to use a geocoder in any way, i.e. a tool that converts addresses to coordinates and vice versa. The ors offers a corresponding endpoint, have a look at the api documentation.

Best regards

hey, thanks for answering, in fact I wasn’t clear enough, I am already using google maps for (maps, geocoding, and search bar), I would like to know if I could use the ORS isochrone api in the google’s maps ?

ps : my goal is that when i enter an address in my search bar, the maps move on the address and draws an isochrone…

Hey,

When stating “google maps”, you’re talking about the API, right?
If so, you can use the result of the geocoding search as an input to an ors API call and you should be able to display the result of the ors API on any map, it should be a geojson polygon.

Best regards

oh, good to know !
I’m currently so bad, i’m looking on the internet and in the documentation, so I know which parameter to use to call the API, but i can’t find how to connect the geocoding api to the isochrone api (probably a basic js line) i mean that the input goes in both API.
Would you give me a clue or a direction to search ?
Thanks a lot anyway !

Hey,

what I meant was to take the output from gmaps geocoding API and input it into ors isochrone API, which would look something like this:

coords = gmaps.geocode("Eiffel Tower, Paris"); //This is pseudocode, don't know gmaps
// ors accepts [[lon, lat]], so we might have to transform coords to conform with this
coords = arrayoperation(coords)

var Isochrones = new Openrouteservice.Isochrones({
                               api_key: apiKey
                     });

Isochrones.calculate({
   profile: 'driving-car',
   locations: coords,
   range:[300,200],
   area_units: 'km'
})

The ors js isochrone example and SDK can be found here.

Best regards

1 Like

Thanks a lot !
you’re so kind right now, (asked the same question on stack overflow and they deleted my post :confused: )
You solved my problem so once again thanks a lot ser.

2 Likes