Creating fixed map view to show multiple routes to same destinations

I’d like to be able to plot multiple routes to our schools. I know the APIs don’t support multiple routes in a single request, so I was going to make multiple requests and layer them on top of each other. However, each request has a different view of the map, so layering isn’t possible. Can I fix the zoom level and area of the map view to keep this constant as I plot different routes?

Hi @DevMcom

I am not sure if I understood your question, specially when you said that “each request has a different view of the map”. The request would be run by your code and the response of ORS API will contain the route data. You can combine the data of multiple routes (with your code) and display all them in a single map view. The zoom level is defined by the code/libraries you are using to display the route data. Usually the libraries used to render geodata, like Leaflet, has the concept of fit bounds, what makes the zoom level to be adjusted to show all the features on the map.

Hi there… thanks for getting back to me… to clarify: if I run your directions service multiple times for all of the different starting points with the same end point for a specific school - I’ll get many map images back with the route shown from the student’s home to the school. The map image will be dependent on the starting point. I understand you’re suggesting I use the route data from your service to create a series of routes and use something like leaflet to display them on a single map. I am curious if there is a way to do this within your environment? Alternatively, I wanted to compute all the individual routes using your service on a “fixed map” so that I could simply overlay the images. Is that possible?

Dev

Hi there @DevMcom

The ORS API does not return map images. The JSON below is a simplification of an example of a route data returned by the API:

{"type":"FeatureCollection","features":[{"bbox":[8.676097,49.416906,110.61,8.683595,49.419724,115.88],"type":"Feature","properties":{"ascent":6.3,"descent":1.4,"segments":[...],"summary":{"distance":0.993,"duration":160.6},"way_points":[0,35]},"geometry":{"coordinates":[[8.676131,49.419724,111.0],[8.676133,49.419663,111.0],[8.676133,49.419594,111.0],[8.676125,49.419477,111.0],[8.67612,49.419308,111.0],[8.676441,49.416906,112.3],[8.676522,49.416906,112.5],[8.676867,49.416914,113.1],[8.683217,49.418555,115.9]],"type":"LineString"}}],"bbox":[8.676097,49.416906,110.61,8.683595,49.419724,115.88],"metadata":{...}

The ORS API does not support the request of multiple routes at once. You have then to perform multiple requests and use some basic programming + libraries to display this data in a map view. But be aware that even if the API supported a multiple routes request, it would still return the route data, and not map view/images. You would still have to use some basic programming + libraries to display this data in a map view.