1

I'm developing a Web Application that is using the ArcGIS Javascript API. When adding a Feature Layer I'm using the setDefinitionExpression to limit the features that are returned. The expression used can be quite large (greater than 2000 in length). Because the expression can be large, I am attempting to use the Proxy page, however I am seeing unusual results. I am finding that the proxy page is not always used, even though I am using the exact same query expression. I have conformed this by utilizing IE's debugger tool and also using Fiddler.

In my application if I add 2 layers (Tiled and Dynamic) prior to adding the Feature Layer I consistently see that the Proxy page is not being used. I can see via the debugging tools that a POST is being performed directly to my REST service. The content-length is over 6000.

If I add just the Tiled layer prior to adding the Feature Layer, I can see that an attempt is made to use the Proxy page. The proxy page is having issues, therefore my Feature Layer does not get added.

Can someone please explain why the Proxy page is not always used even though it would seem that it should be, given the length of the query string used in the setDefinitionExpession. I am very confused as to why layers added prior to adding a Feature Layer would affect the use of the proxy and why adding the Feature Layer doesn't fail when the proxy is not used.

The first function below shows where I am setting the esriConfig.defaults. The second section of code is from my class (tpsMap) where I am adding a Feature layer.

require(["tps/map",
    "esri/config",
    "dojo/domReady!"],
    function (tpsMap, esriConfig) {

        // Setup Esri Config
        esriConfig.defaults.io.proxyUrl = "http://phunt-pc/EsriProxy/proxy.ashx"
        esriConfig.defaults.io.alwaysUseProxy = false;

        // Create and display Map
        tpsMap = new tpsMap(oMapConfiguration);
        tpsMap.mapQuery = oMapQuery;
        tpsMap.createMap("divMap");
    });




this._featureLayer = new FeatureLayer(this.mapQuery.FeatureLayer.url,
       {

            mode: FeatureLayer.MODE_SNAPSHOT,
            opacity: 0.50,
            infoTemplate:    this._getInfoTemplate(this.mapQuery.FeatureLayer.InfoTemplate),
            outFields: this.mapQuery.FeatureLayer.OutputFields,                                       
            className: "feature"
        });

       // Limit the features based on the expession
  this._featureLayer.setDefinitionExpression(this._getQueryExpression());


  this.map.addLayer(this._featureLayer);
  • 1
    Do you have any sample code? – Branco Mar 31 '15 at 19:15
  • I've added sample code in my original post above. – Peter Mar 31 '15 at 20:33
2

my best bet is that adding other layers from the same ArcGIS Server instance is triggering a CORS check by the JSAPI and that since both the server and your browser support CORS, the proxy isn't necessary.

https://developers.arcgis.com/javascript/jshelp/ags_proxy.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.