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.
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
Peter,
Hmm... Do you have a simple sample that can demonstrate this?
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.
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
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,
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.
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?
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