2

I am using a Openlayers 3 to create a Hybrid mapping app and among the constraints it must be for offline use, I have a road network in a geojson file and I need to get the shortest path from the location of the user to a destination following the roads network.

I tried pgrouting before and it worked well but now I need to do so without relying on any server.

Is there any way I can make it with javascript and Openlayers 3? Is there any library that can do offline routing ?

3

If anyone is still looking for an answer to this problem I made a little tool to get the shortest path using dijkstra algorithm in OL3 here

first you create the network based on the feature collection you have :

var network = createNetwork(yourFeatureCollection);

then you get the shortest path as a geometry of the path :

var shortestPath = getShortestPath(network, coordsSource, coordsDestination);
2

GraphHopper is able to run offline in the Browser with the help of TeaVM

  • See here for the examples.
  • See here the blog post about it
  • See here is the source repository

Note: I'm the author of GraphHopper ...

  • Thanks for the answer and thanks for this great tool, I signed up yesterday and began looking around its features. – Hicham Zouarhi Apr 14 '16 at 8:32
  • 'Sign up' you mean probably our commercial took the GraphHopper Directions API ... keep in mind that this works only online! See the link to the source repo for the offline&open source solution :) – Karussell Apr 14 '16 at 13:59
  • thanks for the tip, I am trying to set it up but I can't figure out how. I am new to git so I downloaded the graphhopper-master.zip first but I can't find any js file so I went to the Get started section in your blog, build teavm part was fine ( I guess ) and I cloned the modified Graphhopper, the next command mvn clean package -DskipTests=true got me this error – Hicham Zouarhi Apr 15 '16 at 10:44
  • [ERROR] Plugin org.teavm:teavm-maven-plugin:0.2-SNAPSHOT or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.teavm:teavm-maven-plugin:jar:0.2-SNAPSHOT: Could not find artifact org.teavm:teavm-maven-plugin:pom:0.2-SNAPSHOT -> [Help 1] I have no clue if this is how it must be done, can you help please ? – Hicham Zouarhi Apr 15 '16 at 10:45
  • Please raise the issues related to this project on the github issue page – Karussell Apr 15 '16 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.