Has anyone ever put the results of a RelationshipQuery() into a map.infoWindow that's been replaced with a dijit.popup?

Here's the workflow: User clicks a point, and all identify results are put into popup. <--this part is fine

I'm struggling with calling a relationshipquery, then putting the results into the infoTemplate.

The function findRelatedRecords performs 3 relationship queries and assembles an array of objects that are related to the single point. I cannot get this data back into the executeIdentifyTask function.

The function getWindowContent takes the relationshipquery array and converts it to html and constructs a dijit.tabcontainer & 2 contentpanes (tabs). It return the tabcontainer.domNode.

Any help? I'm really struggling!!

function executeIdentifyTask(evt) {
    identifyParams.geometry = evt.mapPoint;
    identifyParams.mapExtent = map.extent;

    var deferred = identifyTask.execute(identifyParams);

    deferred.addCallback(function(response) {

      // response is an array of identify result objects    
      // Let's return an array of features.
      return dojo.map(response, function(result) {
        var feature = result.feature;
        //feature.attributes.layerName = result.layerName;
        if(result.layerName === 'parcel_area2'){
          var template = new esri.InfoTemplate("", "${site_code} <br/> Owner of record: ${facil_loca}");
        else if (result.layerName === 'logistics2'){
          var template = new esri.InfoTemplate("", "Parcel ID: ${Type}");
        else if (result.layerName === 'query2'){
            findRelatedRecords(feature,evt) //<--get relationship query results here    
            var template = new esri.InfoTemplate("", getWindowContent(data,evt.graphic));

        return feature;
    // InfoWindow expects an array of features from each deferred
    // object that you pass. If the response from the task execution
    // above is not an array of features, then you need to add a callback
    // like the one above to post-process the response and return an
    // array of features.
    map.infoWindow.setFeatures([ deferred ]);


1 Answer 1


I did the following:

dojo.map(response, function (result){
    if (result.layerName === 'mylayer') {
    var relInfo = '';
    // create a new InfoTemplate, and set the title
    var template=new esri.InfoTemplate('Template','${*}');
    // create the RelationshipQuery
    myFeatureLayer.queryRelatedFeatures(relQuery, function(relRecords){
        // build a string of related info
        relInfo = relRecords['myKey'].features[0].attributes['myAttribute'];
    }).then(function() {
        // using the string of related info, setContent for the InfoTemplate here.

And I had to use a timeout to call setFeatures, otherwise the first result of multiple was always blank (the length of the timeout depends on how much related data is being returned):

setTimeout(function() { map.infoWindow.setFeatures([deferred]); }, 1000);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.