diff --git a/README.md b/README.md index bcf9a9a..6f82095 100644 --- a/README.md +++ b/README.md @@ -32,3 +32,18 @@ L.Routing.control({ ``` 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](https://graphhopper.com/api/1/docs/#http-headers): +* `status`: The HTTP status code (see [GraphHopper error codes](https://graphhopper.com/api/1/docs/#http-error-codes)) +* `limit`: The `X-RateLimit-Limit` header +* `remaining`: The `X-RateLimit-Remaining` header +* `reset`: The `X-RateLimit-Reset` header +* `credits`: The `X-RateLimit-Credits` header + +```javascript +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'); +}); +``` diff --git a/examples/index.html b/examples/index.html index b8bdc19..57f02dc 100644 --- a/examples/index.html +++ b/examples/index.html @@ -3,16 +3,16 @@