Search code examples
arcgis-js-api

Featurelayer going to server multiple times for same feature


When creating the most simple layer using ArcGIS javascript api (4.26):

// Creating layer
var myLayer = new FeatureLayer({
    url: "https://...",
    renderer: {
               type: "simple",
               symbol: {
                        type: "simple-fill",
                        color: "yellow",
                        style: "solid",
                        outline: {
                                  color: "red",
                                  width: 1
                                 }
               }
              }
});

// Adding it to the map
view.when(function () {
    view.map.add(myLayer);
});

I am only returning back one feature (objectid). However, opening the network tab in chrome, reveals that it calls the server 3 times for same request. All 3 times it returns the same response with the same objectid. On the request the only parameter I noticed different on the 3 calls is the quantizationParameters sent as part of the request, specifically the xmin,ymin,xmax,ymax values were different on the 3 calls.

I would like to perform only one request to the server and eliminate the duplicate requests to the server.

My question is:

  • How do I turn off "quantize" in arcgis 4.x? (quantize: "false" from arcgis javascript 3.x does not work)
  • What other option is there to only make one request to the server instead of three requests?

Attempts to fix the issue

I tried an old flag (quantize) from ArcGIS Javascript Api 3.x but it has no effect. It still sends the quantizationParameters to the server:

// Creating layer
var myLayer = new FeatureLayer({
    url: "https://...",
    quantize: "false",
...

Thank You


Solution

  • Thanks to Cabesuon's suggestion, I was able to get this working. I was not able to use a FeatureLayer, since using a FeatureLayer even when querying the objects locally would still hit the server when I displayed the FeatureLayer. It is possible that with additional time and knowledge, FeatureLayer might work. But my solution was to query the objects and then use a GraphicsLayer to display them. This worked since there was only one hit to the server during the query. Here is some of the code I used from this example:

    Query a feature layer sql