[GIS] How to use offline routing Dijkstra in javascript

javascriptofflineopenlayersrouting

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 ?

Best Answer

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);
Related Question