Select to view content in your preferred language

Solve route and buffer the route geometry

3837
13
12-15-2015 12:59 PM
MuraliSridhar
Deactivated User

I am trying to the solve the route between 2 points and immediately buffering the route geometry.

I can able to solve the route by using the "Esri/resource-proxy" [sourcehttps://github.com/Esri/resource-proxy/releases], changed the proxy config [with routing URL, client id and client secret] and added proxy rule in my code.

Proxy rule:

urlUtils.addProxyRule({

                        urlPrefix: "tasks.arcgisonline.com",

                        proxyUrl: "http://xxxxx/DotNet/proxy.ashx"

                    });

I have been prompted with ArcGIS online signin popup with user name and password,

After successful authentication, I am passing the route geometry to do and show buffer. But I am getting below exception

"Unable to load http://xxxxx/DotNet/proxy.ashx?http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryS... status: 0"

This time I am setting ""esriConfig.defaults.io.alwaysUseProxy = false", but still this request is using proxy

Question 1: How to get rid of sign in popup? I assumed given client Id and client secret will not prompt popup.

Question 2: How to make buffer request with proxy?

Thanks

Murali

0 Kudos
13 Replies
RobertScheitlin__GISP
MVP Emeritus

Based on the fact that you where getting a login prompt before I would say your proxy has not been working properly yet.

  If you look t this samples description you should get some clues:

Directions | ArcGIS API for JavaScript

//travelModesServiceUrl option points to logistics service hosted from ArcGIS Online

        //by indicating this URL, a login prompt should not display

        var directions = new Directions({

          map: map,

          travelModesServiceUrl: "http://utility.arcgis.com/usrsvcs/servers/cdc3efd03ddd4721b99adce219629489/rest/services/World/Utili..."

        },"dir");

        directions.startup();

0 Kudos
MuraliSridhar
Deactivated User

Robert,

I fixed the routing part yesterday. The issue is proxy is expecting token in config file or in URL.

I also found the reason for second issue do and show buffer, the issue is GeometryService.buffer() is submitting with request method as POST but it is GET method.

My Code :

                      esriConfig.defaults.geometryService = new GeometryService(geometryServiceUrl);

                      esriConfig.defaults.io.proxyUrl = '/proxy/';

                     esriConfig.defaults.io.alwaysUseProxy = false;

                     esriConfig.defaults.geometryService.buffer(params, showBuffer);

param = bufferparameter and show buffer is callback method.

I am using the same code in another widget, its submitting as GET.

The only difference is, In this widget first I am using the "Esri/resource-proxy" for routing and I am using  '/proxy/' and alwaysUseProxy = false for GeometryService.

Will that is making any difference?

Is there any way to set request method as GET for GeometryService.buffer() manually?

Thanks

Murali

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Murali,

   Esri will switch to POST automatically when the url string exceeds the length that your particular browser can support with GET.

You could look into setRequestPreCallback

esri/request | API Reference | ArcGIS API for JavaScript

0 Kudos
AndrewNault1
Deactivated User

This is a really good comment.

0 Kudos