I have a web application based on ArcGIS API for Javascript 3. In the web application a QueryTask is executed on a MapServer feature layer. The result feature set is used to create a Feature Layer and displayed on the map. Here is a piece of the Javascript source code.
getFeatures: function(layer) {
let query = new Query();
query.returnGeometry = true;
query.outSpatialReference = this.map.spatialReference;
query.where = this.createWhereQuery();
query.outFields = ["*"];
layer.queryTask.execute(query, lang.hitch(this, function (featureSet) {
if (featureSet.features.length > 0) {
console.log(featureSet.features);
let geomType = "esriGeometryPoint";
let layerDefinition = {
"geometryType": geomType,
"fields": [{ name: "OBJECTID", type: "esriFieldTypeOID", alias: "OBJECTID" }]
}
let featureCollection = {
layerDefinition: layerDefinition,
featureSet: featureSet
};
let clusterLayer = new FeatureLayer(featureCollection, {
outFields: ["*"],
featureReduction: {
type: "cluster"
}
});
this.map.addLayer(clusterLayer);
}),
lang.hitch(this, function (error) {
console.log(error);
alert("Unable to load points data. Contact server administrator.");
}));
}
Everything worked as excepted when MapServer used data from ESRI File Geodatabase. Recently we created a Postgresql database and published an identical copy of MapServer where data comes from the Postgresql database.
After replacing new MapServer URLs in the web application, I noticed that only single feature is displayed on the map after executing above QueryTask. Nothing, except the URLs, was changed in the Javascript code.
When printing in browser console featureSet.features, I noted that the first feature object looks different than the rest (console print screen below). Private properties are present in the first feature object, and not present in the rest feature objects. I guess this is the reason why only a single feature (the first one) is displayed on the map.
When printing in browser console the same featureSet.features using Mapserver with data from ESRI File Geodatabase, then all feature object look similar to the first one described above, and all features are displayed on the map.
Where is the problem and how to fix it?
-
This is solved now on the other forum community.esri.com/t5/arcgis-javascript-maps-sdk-questions/…Andžej Miloš– Andžej Miloš2025年02月27日 12:03:35 +00:00Commented Feb 27 at 12:03
-
You can answer your own question with the solution from other forum. It may help somebody with similar/same problems.TomazicM– TomazicM2025年02月27日 19:58:40 +00:00Commented Feb 27 at 19:58
1 Answer 1
This is solved now. Answered in the other forum https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/arcgis-api-for-javascript-3-querytask-execute/m-p/1589805
-
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.2025年02月28日 08:14:13 +00:00Commented Feb 28 at 8:14
-
Please don't just give link to the answer, post answer itself. Links tend to get lost in time.TomazicM– TomazicM2025年02月28日 17:55:06 +00:00Commented Feb 28 at 17:55
Explore related questions
See similar questions with these tags.