Select to view content in your preferred language

Confusion over lack of features displayed from 'new FeatureLayer'

1550
9
09-05-2017 06:28 PM
PeterLen
Frequent Contributor
Hello,

The services that I will be referring to are not public-facing, so I am hoping I can explain it properly.  I am loading a feature class via a MapServer service in the following manner:
var layer = new FeatureLayer(url, { mode: Featurelayer.MODE_ONDEMAND });
this.map.addLayer(layer);
When this happens, the polygon features are displayed on my map.  Because it is listed with the MODE_ONDEMAND, only the polygon features within the viewport are listed in the layer's "graphics" array and displayed on the map.  The service has a maxRecordCount of 1000, but depending on the map extent, there may be more than 1000 features displayed.  My understanding is the maxRecordCount is used for query responses, which is not really what is going on in this example.

I have another feature class via a MapServer service (points) that also has a maxRecordCount of 1000 and also has a relationship table (a non-spatial audit table).  When I create a new FeatureLayer for this service with the same definition type, I find that I am only getting 1000 features back even though there are about 9000 total features.  When I try to load the non-spatial relationship table using the "new FeatureLayer", I again am only getting 1000 items even though that table has many more objects.

I am trying to find out why the one service is populating the one FeatureLayer with more features than the maxRecordCount, while the other services (one for the other feature class and one for the relationship table) are only populating the FeatureLayer with an amount equal to the maxRecordCount.  As a note, there are no restrictions on the services that are only returning the an amount equal to the maxRecordCount, such as having to be at a certain zoom level before features are displayed.

I am hoping that somone can point me in the right direction.  I can't find anything in particular in the service metadata that might indicate something.  The only thing that is different is that I don't own the data for the service that is displaying more features than the maxRecordCount but do own the other service.  I am wondering if there is some service setting that I am not seeing.  Again, I am not doing any type of query (such as layer.queryFeatures). 

Thanks for any insight - Peter
0 Kudos
9 Replies
RobertScheitlin__GISP
MVP Emeritus

Peter,

The service has a maxRecordCount of 1000, but depending on the map extent, there may be more than 1000 features displayed.

I am pretty sure this statement is incorrect. The maxRecordCount controls the number of features returned from the server when using a query or feature layer (which need to return the actual geometry). The only time that you would get more than 1000 features in the map is when you are using ArcGISDynamicMapServiceLayer which returns an image from the server and not the actual features.

0 Kudos
PeterLen
Frequent Contributor

Robert,


Thanks for the reply. I hear what you are saying, and I thought that was the way it was supposed to behave, but my example isn't showing that behavior. After the map is loaded, I simply do the following:

var layer = new FeatureLayer(url, {
      mode: Featurelayer.MODE_ONDEMAND,
      outField:["*"],
      id : "idx1"
});
this.map.addLayer(layer);

Once the layer is added to the map, the polygons start to appear. Looking at the graphics array for that layer in javascript, I can see that the array will have far more features than the maxRecordCount of 1000 indicates. As I pan the map or change zoom levels, the number of features in that layer change, but if my map extent is big enough, I will easily get more than the maxRecordCount of 1000. Internally, I do not know what the Esri Javascript API is doing to update the layer's graphics array, but it certainly is getting more than the maxRecordCount.

As a side note, we are still back on the Esri Javascript API v3.9.  

/ Peter

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Peter,

  Hmm... Do you have a simple sample that can demonstrate this?

0 Kudos
PeterLen
Frequent Contributor

My test suite and the services I am using are not public-facing so I will try to gen up an example elsewhere.  I am just not sure where I can find an appropriate service to use.  I will try tonight.

0 Kudos
PeterLen
Frequent Contributor

Robert,

Okay, here is an example.  Just copy and paste in an HTML file.

---------------------------------

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>Overview Map</title>
<link rel="stylesheet" href="https://js.arcgis.com/3.21/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="https://js.arcgis.com/3.21/esri/css/esri.css">
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
</style>

<script src="https://js.arcgis.com/3.21/"></script>
<script>
var map;

require([
"esri/map", "esri/dijit/OverviewMap",
"esri/layers/FeatureLayer",
"dojo/on",
"dojo/_base/lang",
"dojo/parser",

"dijit/layout/BorderContainer", "dijit/layout/ContentPane", "dojo/domReady!"
], function (
Map, OverviewMap, FeatureLayer, on, lang,
parser
) {
parser.parse();

map = new Map("map", {
basemap: "topo",
center: [-85.050200, 33.125524],
zoom: 4
});

var LAYER;
on.once(this.map, "load", lang.hitch(this, function() {
var url = "http://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/counties_politics_poverty/FeatureSe...";
this.LAYER = new FeatureLayer(url, {
mode: FeatureLayer.MODE_ONDEMAND,
outField:["*"],
id : "idx1"
});
this.map.addLayer(this.LAYER);
setTimeout(displayCount, 6000);
}));

on(this.map, "click", lang.hitch(this, function() {
alert("Service Max Record Count = 2000. Feature Count: " + this.LAYER.graphics.length);
}));

function displayCount() {
alert("Service Max Record Count = 2000. Feature Count: " + this.LAYER.graphics.length);
}


});
</script>
</head>

<body class="claro">
<div data-dojo-type="dijit/layout/BorderContainer"
data-dojo-props="design:'headline', gutters:false"
style="width: 100%; height: 100%; margin:0;">

<div id="map"
data-dojo-type="dijit/layout/ContentPane"
data-dojo-props="region:'center'"
style="padding:0">
</div>
</div>
</body>
</html>

---------------------------------

/ Peter

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Peter,

   OK the reason for this is that the layer is coming from AGOL and actually has these attributes:

"maxRecordCount":2000,"standardMaxRecordCount":4000,"tileMaxRecordCount":4000,
0 Kudos
PeterLen
Frequent Contributor

Not sure if that really explains it, especially for my services.  Documentation indicates that the standardMaxRecordCount and tileMaxRecordCount use is determined by the metadata's resultType and the resultType parameter is only supported if the layer metadata returns supportedQueryWithResultType is true in the advancedQueryCapabilities metadata object.  For the service in this example, the supportedQueryWithResultType is indeed set to true, although there is no resultType property. This test example service is using a 10.51 ArcGIS Server, whereas we are on v10.41 so it is possible that your reference is allowing it to work in this sample, but our services do not list a supportedQueryWithResultType property and do not have those other max record count properties.  I believe you are on the right track, however, and it is likely a service-related property of some sort.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Peter,

  So if you enter your map service url in your browser with ?f=pjson you do not have the tileMaxRecordCount or the standardMaxRecordCount properties?

0 Kudos
PeterLen
Frequent Contributor

Robert,

Thanks for sticking with me on this.  I believe that I found my answer.  As for your last question, that is correct.  There are no tileMaxRecordCount or standardMaxRecordCount properties when looking at the JSON.  In looking at the network activity for this test service, I did see the parameter for "resultType=tile", so it likely would return up to 4000 features for this particular service.  What I also saw in the network activity for both this test page and my web page at work is that the Esri JavaScript API is making 6 sub-queries when it loads the layer.  It appears that each query is for a different geographic region.  In the case where I was getting a lot more features than the maxRecordCount, it was a world-wide service so my guess is that there was not any single region that reached that max limit and so the total of each of the 6 sub-queries was able to return all of those features.  In the case where my other service was only returning that the maxRecordCount was, the service was more of a regional service so 1 of the 6 sub-queries would max out at the 1000 and the other 5 sub-query regions did not have any features.  As for the loading of the non-spatial table, it possibly looks like because there is no spatial element in the table, each of the 6 queries returned the same 1000 results (the maxRecordCount) and the result of that may have been only 1 version of each of those 1000 features was added to the graphics array.  I would have to look closer at the object IDs for the results in the different sub-queries, but I did see that each of the 6 returned 1000 records.

So, I think the problem is solved.  I don't want to delve too much further into this as I believe the results I was seeing correspond to what I saw in the network activity and I am satisfied with that explanation.  I also am talking to a former co-worker, who is an Esri software engineer to have him verify this explanation.

Thanks again for your time - Peter 

0 Kudos