I have a Feature Service in my ArcGIS for Server 10.1 that displays features in a concrete world region. This same service, has a relationship with a table in my database, so every feature represented in the map, has attached several record I would like to display. At first, just for practising, I tried this example that shows the related records in a side grid, but then I decide it would be better and compact to display those records on a Popup, as this example shows.But it turns out that after querying the related records and making sure that I have received them correctly, putting them on an Array of Features (or Deferred) and passing all those results to the Popup.setFeatures(Features[] | Deferred[]) the results are not displaying in the popup. I searched on this same forum and on GIS StackExchange and found some people similar problems, but I do not see a clear workaround.The funny thing is that the title part of the Popup presents the counter of the total number of related records for that feature, so I think that Popup does receive the Array of Features. I am attaching an image to make it clear:[ATTACH=CONFIG]21916[/ATTACH]Therefore...is there anything wrong in my features? They are the result of a queryRelatedFeatures so I am not sure of how much can I modify this output to match the Popup. And, in the end, if this function returns an array of features, why setFeatures() is not displying them? Something missing? Maybe a parameter?Here is my code: dojo.connect(map,"onClick",function(evt){
var query = new esri.tasks.Query();
query.geometry = pointToExtent(map,evt.mapPoint,10);
var deferred = featureLayer.selectFeatures(query,esri.layers.FeatureLayer.SELECTION_NEW);
deferred.then(function (results) {
dojo.forEach(results, function(res){
var relatedTopsQuery = new esri.tasks.RelationshipQuery();
relatedTopsQuery.outFields = ["*"];
relatedTopsQuery.relationshipId = 0;
relatedTopsQuery.objectIds = [res.attributes['OBJECTID']];
reldeferred = featureLayer.queryRelatedFeatures(relatedTopsQuery, function(relatedRecords) {
var fset = relatedRecords[res.attributes['OBJECTID']];
dojo.forEach(fset.features, function(feature){
feature.attributes.StartDate = Date(feature.attributes.StartDate).toLocaleString();
feature.attributes.EndDate = Date(feature.attributes.EndDate).toLocaleString();
feature.setGeometry(evt.mapPoint);
featureArray.push(feature);
});
map.infoWindow.setFeatures(featureArray);
map.infoWindow.show(evt.mapPoint);
featureArray = [];
}); // close related deferred
}); // close for each
}); // close deferred then
});
I tried to pass to the setFeatures function the array of features I am building and the deferred once it is created. But the output is similar: the array returns what the image shows and the deferred something like "No information available". I have been struggling with this several days and I am completely stuck, please, can anyone provide some help? 🙂Thanks to all!