Reputation: 463
So i am trying to use an ESRI Route service in a Leaflet map using https://github.com/jgravois/lrm-esri and am getting an error that maybe someone can help me with. Even using the code provided at git, i still seem to get the error, it would seem it worked at one time.
{status: -3, message: "TypeError: Cannot read property 'lat' of undefined"}
here is the js
var control = L.Routing.control({
waypoints: [
L.latLng(28.4644,-99.0236),
L.latLng(28.4758,-98.6424)
],
router: L.Routing.esri({
//this is a sample service, i am using one i created using private roads
serviceUrl: 'https://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Network/USA/NAServer/Route'
}),
geocoder: L.Control.Geocoder.nominatim(),
routeWhileDragging: true,
reverseWaypoints: true
}).addTo(map);
L.Routing.errorControl(control).addTo(map);
Has anyone gotten the lrm-esri to work recently? The service is working for solve route, but it must be a way the js is passing the lat longs to the service?
Upvotes: 0
Views: 803
Reputation: 404
it might be a typo, but your lat/longs are reversed
L.latLng(28.4644,-99.0236),
L.latLng(28.4758,-98.6424)
once that's fixed, you're correct that sampleserver3 is solving the route, but for some reason cors-lite
throws an error immediately, before the response can even be parsed.
one thing i know about that server is that it does not actually support CORS. i'm just guessing, but perhaps the support for cross domain requests it allows for in ancient browsers requires CORS support on the server (and it just so happens to be missing from your own internal service as well).
because of this, your best bet would be to try to either add support for CORS to your own routing service or substitute another dependency in place of cors-lite
.
Upvotes: 1