I find featurelayer with arcgis for js 4.0 can load large data form server with "pagination", like this "Axis politics ".
so I try to Realization it without the pagination,my code i
var queryTask = new QueryTask({ url: "http://*******/arcgis/rest/services/Test/MapServer/1" }); var time = 0; function querydata() { for (var i = 0; i < 8; i++) { var query = new Query(); query.returnGeometry = true; //query.outFields = ["OBJECTID", "RELHEI", "name"]; query.outFields = ["*"]; var start = 0 + i * 1000 var end = start + 1000 query.where = "OBJECTID > " + start + " AND OBJECTID < " + end; queryTask.execute(query) .then(function (results) { time++; var l = results.features; if (time == 8) { myMap.add(querylayer); } collection.addMany(results.features); querylayer.source = collection; }) .otherwise(function (error) { console.log(error); }) } }
I load the 8000 polygon. I find it slow, the featurelayer render all the geometry once ,it not render 8 times.how to realize render the featurelayer one by one?????
You could add all the result features in a bigger array and then add them all at once:
var queryTask = new QueryTask({ url: "http://*******/arcgis/rest/services/Test/MapServer/1" }); var time = 0; function querydata() { var allFeatures = []; // array for all resulting features for (var i = 0; i < 8; i++) { var query = new Query(); query.returnGeometry = true; //query.outFields = ["OBJECTID", "RELHEI", "name"]; query.outFields = ["*"]; var start = 0 + i * 1000 var end = start + 1000 query.where = "OBJECTID > " + start + " AND OBJECTID < " + end; queryTask.execute(query) .then(function(results) { time++; var l = results.features; //collection.addMany(results.features); allFeatures.push(results.features); if (i == 8) { // add when final result set has been retrieved collection.addMany(allFeatures); querylayer.source = collection; myMap.add(querylayer); } }) .otherwise(function(error) { console.log(error); }) } }