0

因此,我正在尝试使用https://github.com/jgravois/lrm-esri在传单地图中使用 ESRI Route 服务,并且遇到了一个错误,也许有人可以帮助我。即使使用 git 提供的代码,我似乎仍然收到错误,它似乎一次有效。

{status: -3, message: "TypeError: Cannot read property 'lat' of undefined"}

这是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);

最近有没有人让 lrm-esri 工作?该服务正在为解决路线工作,但它必须是 js 将经纬度传递给服务的一种方式?

4

1 回答 1

0

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.

于 2018-06-08T17:23:02.950 回答