Awesome
Leaflet Routing Machine - Esri plugin
enables walk, drive and truck routing using Esri's hosted service.
Demo
Check out the live demo.
Usage
<script src="./lrm-esri.js"></script>
/*
additional profiles:
Walking, Trucking, Rural Driving, Walking Distance, Trucking Distance, Driving Distance and Rural Driving Distance
*/
var control = L.Routing.control({
router: L.Routing.esri({
liveTraffic: true,
profile: 'Driving'
})
}).addTo(map);
Features
Esri's hosted routing service can find the shortest driving, truck and walk time or distance for up to 150 input stops. It is able to incorporate both live and historic traffic and can reorder input stops to find the optimal sequence.
Authentication
Use a proxied service
You can allow anonymous users to get directions in your application by leveraging a proxied service - live demo
- Sign up for a free developer account
- Create your own proxied service url
- supply the
url
in the provider constructor
var control = L.Routing.control({
router: L.Routing.esri({
url: '<your proxied service url>'
})
}).addTo(map);
When credentials are embedded, 1250 requests/month are provided for free. Deployment packs are available to help you scale.
Use OAuth2
You can also use OAuth2 and bill routing charges directly to existing ArcGIS users - live demo
- Sign up for a free developer account
- Create and register a new application
- Reference your
clientID
in your app and configure aredirectUri
- after the user signs in, supply their
token
in the provider constructor (more info here)
var control = L.Routing.control({
router: L.Routing.esri({
token: '<user token>'
})
}).addTo(map);
Development Instructions
If you'd like to inspect and modify the source code, follow the instructions below to set up a local development environment.
- Fork and clone
cd
into thelrm-esri
folder- Install the
package.json
dependencies by runningnpm install
- Run
npm start
from the command line. This will recompile minified source in thedist
directory, launch a tiny webserver and begin watching the raw source for changes. - Run http://localhost:8080/examples/index.html to check out your changes
- Create a pull request
Dependencies
- leaflet
- leaflet-routing-machine
- cors-lite
esri-leaflet
Resources
Issues
Find a bug or want to request a new feature? Please let us know by submitting an issue.
Contributing
Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.
Caveats
Many Esri routing service features have not been implemented
- barriers
- route optimization
- driving, trucking and walking distance
- time windows
- routing for emergency vehicles
Licensing
Copyright © 2017 Esri
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
A copy of the license is available in the repository's LICENSE file.