POST request to display route on graphhopper-maps

  • I have a local instance of graphhopper running on port 8989
  • I have a local instance of graphhopper-maps running on port 3000

I would like to send a post request to graphopper-maps on port 3000 with a route, to then be displayed on the port 3000 map.

I would ideally use the URL (http://localhost:3000/?point=[lat],[lon] etc.), however I have quickly run into a URL limit issue meaning that this is not a viable option for my application.

It seems the only way forward is to handle post requests from the graphhopper-maps repo, however I am hoping there is a simpler solution out there. Any help is greatly appreciated. Thank you.

Iā€™m not sure I fully understand your question, but if you are running graphhopper-maps from source you can edit the routingApi field of config.js so it points to your GraphHopper server running on port 8989.

Thanks for the quick reply - I will try to clarify on my message above.

I have pointed my graphhopper-maps server (port 3000) to the graphhopper instance (port 8989) using config.js. What I would like to do is make a post request from an external application (via the terminal) to send data as a post request to then be displayed on my graphhopper maps instance on port 3000.

Hope that helps to clarify my issue.

You could use our API explorer (see it live here). It allows pasting a complete POST request body. Does this help?

RESOLVED
I have come up with a solution to my issue, in case someone else has the same problem as I did.

Quick Summary:
Initially, my problem was that I wanted to display a large number of points onto the map as a route. Using the GET request to graphhopper-maps failed as the URL string was too long. To my understanding, this is a browser limitation, and the best alternative is to use a POST request. The POST request was successful, however it did not update the graphhopper-maps with the requested points, it just returns a json string.

Solution:
I am now using graphopper purely as a backend and no longer using graphopper-maps as a front-end for my application. Instead I am now running leaflet through a locally hosted flask server. This allowed me to create a custom POST request handler which receives a JSON formatted string as input, and then displays the points on the leaflet map using the leaflet polyline function.

1 Like