A OSM API passthrough

I just wanted to know if there was a way of using the OSM get requests to passthrough my current GPS coordinates to get a pin on the map through Graphhopper. I basically want to be able to create a live navigation of a Graphhopper route. Is there some other way of doing this?

This isn’t implemented yet, but I also think it would be very useful to have some kind of ‘zoom to current location/show current location/track current location’ feature. There is also navi.graphhopper.org (see Turn-by-Turn Voice Navigation in the Browser by karussell · Pull Request #279 · graphhopper/graphhopper-maps · GitHub).

I also added this issue: Zoom to current location button · Issue #282 · graphhopper/graphhopper-maps · GitHub

1 Like

Thank you for the rapid response. So refreshing to get help this quick. Is there a respository for this?

The GraphHopper routing engine / server is here
And the GraphHopper maps app is here

If you are keen to do it yourself it’s probably not so hard to implement.

I am currently building a university project that demonstrates the capabilities of Graphhopper for developers. I have the github version GH 6 compiled with maven on my PC. I notice there is a folder called navigation. However, there dosent seem to be any navigation endpoints when running the web server. Am I missing something? Is there a way to use this navigation system like this link from the open source respository? And if so can it be done without an API key because I have custom encoded values that I need as part of the demonstration. Graphhopper Maps

However, there dosent seem to be any navigation endpoints when running the web server. Am I missing something?

Are you sure? Take a look at the server output there should be a message like:

2022-11-13 09:15:05.715 [main] INFO  i.d.jersey.DropwizardResourceConfig - The following paths were found for the configured resources:

    GET     / (com.graphhopper.application.resources.RootResource)
    GET     /health (com.graphhopper.resources.HealthCheckResource)
    GET     /i18n (com.graphhopper.resources.I18NResource)
    GET     /i18n/{locale} (com.graphhopper.resources.I18NResource)
    GET     /info (com.graphhopper.resources.InfoResource)
    GET     /isochrone (com.graphhopper.resources.IsochroneResource)
    POST    /match (com.graphhopper.resources.MapMatchingResource)
    GET     /mvt/{z}/{x}/{y}.mvt (com.graphhopper.resources.MVTResource)
    GET     /navigate/directions/v5/gh/{profile}/{coordinatesArray : .+} (com.graphhopper.navigation.NavigateResource)
    GET     /nearest (com.graphhopper.resources.NearestResource)
    GET     /route (com.graphhopper.resources.RouteResource)
    POST    /route (com.graphhopper.resources.RouteResource)
    GET     /spt (com.graphhopper.resources.SPTResource)

The /navigate endpoint is the one that runs the code in the navigation folder: GitHub - graphhopper/graphhopper: Open source routing engine for OpenStreetMap. Use it as Java library or standalone web server.

However, this is not related to the GraphHopper Maps app at all, not even the version running under navi.graphhopper.org.

Is there a way to use this navigation system like this link from the open source respository? And if so can it be done without an API key

Yes, it is part of the open source server and no API key should be needed for this.

because I have custom encoded values that I need as part of the demonstration

I’m not sure, because the /navigate endpoint converts the GraphHopper endpoint to the special format needed for the mapbox navigation sdk. @karussell?

I’m not sure, because the /navigate endpoint converts the GraphHopper endpoint to the special format needed for the mapbox navigation sdk. @karussell?

Yes, this endpoint is for the Maplibre Navigation SDK (should work with mapbox too). And customizing this endpoint is indeed hard as you need support on the client side too.

The turn-by-turn navigation of GH Maps instead uses the normal and much more powerful /route endpoint where you could use custom models etc (still this is currently not implemented).

Thank you both for your responses. Really awesome stuff!

1 Like

I am pointing Graphhopper-maps at my Graphhopper server which is running a local map and for some reason the current and destination search to find a route is not working.

You should check:

  • the browser logs (open dev tools using the F12) key, are there any errors?
  • the dev tools network tab, do you see /route requests against your local GH server?
  • the server logs, are there any route requests coming in?

Im getting this
Api.ts:78
GET http://server-address:8989/geocode?key=&q=9+He&provider=default&locale=en 404 (Not Found)
geocode @ Api.ts:78
Uncaught (in promise) Error: Could not get geocoding results because: Error: Geocoding went wrong 404
at Geocoder.requestAsync (AddressInput.tsx:259:19)

/geocode is not part of the GraphHopper server. You could use an online geocoder like the GraphHopper Directions API for this or host your own geocoder like Nominatim or Photon.

I would like to use the GraphHopper directions API and pay for it, but I have custom encoded values I am reading from a custom map. Is there a way to do both of these things. I am specifically overriding the custom weighting for a lighting data on edges.

Yes, you can combine the geocoding from the Directions API (unrelated to custom encoded values etc.) and the routing from your local server.

Are you using GH 6.x (with the olds map client) or the current master branch (with the new maps client)? For 6.x you can specify different hosts for geocoding and routing as I explained here: Regarding Hosting the Graph Hopper on Private Server - #4 by easbar, but for latest master maybe we need to make the configuration more flexible to do this first.

I am using GH 6.x. I have done the same thing as the other person, but with your addition and Im still getting the 404 error. There is no endpoint /geocode. Do I need to rebuild with Maven after these changes?

exports.options = {
    with_tiles: true,
    environment: "development",
    // use this if you serve the web UI from a different server like live-server and the GH server runs on the standard port
    routing: {host: 'http://localhost:8989', api_key: ''},
    geocoding: {host: 'https://graphhopper.com/api/1', api_key: '0c73fed7-42ff-46da-9ed6-cfec11801b6f'},
    thunderforest: {api_key: ''},
    omniscale: {api_key: ''},
    mapilion: {api_key: ''}
};

Yes, you need to rebuild the server or at least re-create the JavaScript bundle (npm run bundleProduction).

Did that. What is happening is that GH-maps running on port 3000 is pointing to my GH server on port 8989, and trying to do a get request to /geocode on the GH server on 8989, but there is no endpoint like that matches this. Is there something Im missing? Is there a way to do local geocoding on GH-maps and then passing the point request?

Ok, first thing you might have missed is that the GH 6.x server already includes the GH maps app (the old one). So when you start the GH server the app becomes available at http://localhost:8989/maps/ (port 8989 is the default). In this case I think there is basically nothing else you need to do, unless you want to enable the address search in which case you need to set the geocoding host and api_key in options.js just like you did above and then rebuild the server (or at least the JavaScript bundle as I mentioned above).

But since you said GH-maps was running on port 3000 I assume you are trying to use the new maps app from https://github.com/graphhopper/graphhopper-maps? This does not allow using a separate geocoding host yet, but this will be fixed soon

Powered by Discourse