-
Notifications
You must be signed in to change notification settings - Fork 353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load route from variable #195
Comments
Yes, set alternatives takes an array of routes (the alternatives), but it looks like you're passing a single route. control.setAlternatives([JSON.parse($scope.trip.lineString)]); would probably fix this. |
Thank you for your answer, but now I'm getting:
Can it be that after deserialization the L.LatLng became just object?
|
Yes, you are right. I remember that the code assumes a route's As a hack, you can of course make the coords into latlngs when deserializing, but maybe there should be some change in LRM to make this easier. |
Please have you solved this problem: control.setAlternatives([JSON.parse($scope.trip.lineString)]); |
@esurnet as mentioned above, the issue is that the JSON's A pull request to address this would be welcome, but my own time for developing Leaflet Routing Machine is very limited at the moment, so don't expect me to address this any time soon. |
Thanks |
I had the same problem and yes, it is to do with the LatLng object. The problem can be traced to in _extendToWayPoints method: wpLatLng = L.latLng(wps[i].latLng); The first variable has been cast using Leaflet L.latLng, but not the second, where it blows out. routeCoord = L.latLng(this._route.coordinates[wpIndices[i]]); appears to solve the problem for me... |
its working! let route = JSON.parse(...);
route.inputWaypoints.map(e => e.latLng = L.latLng([e.latLng.lat, e.latLng.lng])); // **fix latLng**
control.setAlternatives([route]); |
Hi,
My project is based on angularjs. I'm saving route by using:
and save this to a database. Later when trying to load the route
control.setAlternatives(JSON.parse($scope.trip.lineString));
I'm getting:The text was updated successfully, but these errors were encountered: