| Forum | GitHub | Maps | Blog

How to use my own map server?


Hello there,

I’m working on a project with my school, so I downloaded and installed the open source version of graphhopper.
Our goal is to make an open source hiking circuit generator with the help of graphhopper.

We have a VM dedicated to our project, so I already downloaded the Brittany map from OSM France to use it. But since this is hosted on a VM, I have the problem with the API key.

Is there any way not to use Omniscale or thunderforest ?
Maybe my own map server or an open-source with no pricing requirements ?

(I already found a link that explains how to make my own map server, I just don’t know how to implement it …)

Thanks !


If i’m understanding it right, you want to create your own server to calculate distances or routes?

You can create a java webservice (for example with spring-boot and the spring rest api) and integrate graphhopper into it.

You can use the following tutorial to create a graphhopper instance: Stable 0.9 Java development

Put it in your constructor:

GraphHopper hopper = new GraphHopperOSM().forServer();
// where to store graphhopper files?
hopper.setEncodingManager(new EncodingManager("car"));

// now this can take minutes if it imports or a few seconds for loading
// of course this is dependent on the area you import

Put that in your REST endpoint:

GHRequest req = new GHRequest(latFrom, lonFrom, latTo, lonTo).
GHResponse rsp = hopper.route(req);

// first check for errors
if(rsp.hasErrors()) {
   // handle them!
   // rsp.getErrors()

// use the best path, see the GHResponse class for more possibilities.
PathWrapper path = rsp.getBest();

// points, distance in meters and time in millis of the full path
PointList pointList = path.getPoints();
double distance = path.getDistance();
long timeInMs = path.getTime();

If you have to create a new flagEncoder (a flagEncoder decides if you can use a route or which routes you can use. To understand it, use the as an example. Also use the osm wiki to understand the different flags and maybe what flags you need to discribe a way as acceptable(usable) or not. Also look at if you want to know how to store data for later use for example.

Hopefully that will answer your questions.


@martin.staehr :+1: … so, yes customizing a vehicle profile currently needs Java knowledge

You can switch to openstreetmap in the right button, to make this the default you would need to customize the JS files


@martin.staehr that is not what I was looking for … But thanks anyway !

@karussell so basically, all I need to do is comment lines with omniscale and thunderforest ?
I’ll try this afternooon


You need to set up the JS part: to recreate the main.js


Oh sorry, so I misunderstood your question.


i’m way too dumb…

I didn’t even notice the layer on the top right corner … thanks !