A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.npmjs.com/package/lrm-graphhopper below:

lrm-graphhopper - npm

Leaflet Routing Machine / GraphHopper

Extends Leaflet Routing Machine with support for GraphHopper.

Some brief instructions follow below, but the Leaflet Routing Machine tutorial on alternative routers is recommended.

Installing

Go to the releases page to get the script to include in your page. Put the script after Leaflet and Leaflet Routing Machine has been loaded.

To use with for example Browserify:

npm install --save lrm-graphhopper

Using

There's a single class exported by this module, L.Routing.GraphHopper. It implements the IRouter interface. Use it to replace Leaflet Routing Machine's default OSRM router implementation:

var L = require('leaflet');

require('leaflet-routing-machine');

require('lrm-graphhopper'); 

 

L.Routing.control({

    router: new L.Routing.GraphHopper('your GraphHopper API key'),

}).addTo(map);

Note that you will need to pass a valid GraphHopper API key to the constructor.

To keep track of the GraphHopper credits consumption, the application may listen to the response event fired by the Router object. This event holds the values from GraphHopper's response HTTP headers:

var router = myRoutingControl.getRouter();

router.on('response',function(e){

  console.log('This routing request consumed ' + e.credits + ' credit(s)');

  console.log('You have ' + e.remaining + ' left');

});


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4