Saving the results of a route request into a Feature Layer?

498
3
03-24-2021 07:41 AM
RobBoothIBM
New Contributor II

I've successfully called the NAServer route API and using returnRoutes=true, I have an object within my javascript that contains the results of my routing request.

How can I add this to a feature layer so it gets permanently stored?

I've tried using layer.add and applyEdits but nothing seems to happen, and I don't appear to get any error messages.

This is my first time battling with javascript and the ESRI SDK, so I might be making foolish errors.  So, 

1) Is the route object returned from the routing service a valid geometry to save in a feature layer?

2) Do I have to create a feature layer first to save it to?  Does it have to have the exact same attributes?

3) Has anybody ever done this, and can point me at some sample code that might help?

Many thanks in advance

Rob

0 Kudos
3 Replies
Noah-Sager
Esri Regular Contributor

Hi @RobBoothIBM, currently, we do not support saving the RouteLayer yet with 4x. This functionality is under active development, and should be coming soon.

0 Kudos
RobBoothIBM
New Contributor II

Thanks for the reply.  If I generate my own APIs to save and load the routes, is it possible to add these results to a layer/directions object and have them display as per normal, without having to re-calculate the route?

0 Kudos
Noah-Sager
Esri Regular Contributor

I think it might be possible to save it as a feature collection, but I don't know how "smart" it would be. We've been actively working on this.

0 Kudos