Query dynamicmapservice related tables

516
0
10-11-2016 08:14 AM
OliviaGill1
New Contributor

I'm using identify to return info about multiple DynamicMapServiceLayers, and using the initializeSidebar function rather than a popup. This works fine but 3 of my services contain related data in a table that I'd like to identifya layer on so that it brings back the related fields in an additional side panel that's different from the initial identify

For example I identify layer 1 - it has a field called UNIT1. That field is related to table 1 field UNIT2. I want the additional relationship identify to return all the data in the table including 'UNIT2' in a different side panel.

I've carried out a bit of research online but can't really understand how to return the related fields. Can anyone help?

This is the first part of my code to identify the layer:

function executeIdentifyTask(event) {

IdentifyParams.geometry = event.mapPoint;
IdentifyParams.mapExtent = map.extent;

var deferred = identifyTask
.execute(IdentifyParams)
.addCallback(function (response) {
// response is an array of identify result objects
// Let's return an array of features.
return arrayUtils.map(response, function (result) {

var feature = result.feature;

var layerName = result.layerName;

feature.attributes.layerName = layerName;
if (layerName === 'My Layer') {

var taxParcelTemplate = new InfoTemplate("",
"My layer <br/> <b>UNIT1:<b> ${UNIT1} ");

feature.setInfoTemplate(taxParcelTemplate);
}

return feature;

});
});

map.infoWindow.setFeatures([deferred]);
map.infoWindow.show(event.mapPoint);
}

This is the 2nd part to add the results of the identify in a side panel;

function initializeSidebar(map) {
var popup = map.infoWindow;

//when the selection changes update the side panel to display the popup info for the
//currently selected feature.
connect.connect(popup, "onSelectionChange", function () {
displayPopupContent(popup.getSelectedFeature());
});

//when the selection is cleared remove the popup content from the side panel.
connect.connect(popup, "onClearFeatures", function () {
//dom.byId replaces dojo.byId
//dom.byId("featureCount").innerHTML = "No features were selected, click again on the map layer";
//registry.byId replaces dijit.byId
$("#leftPane").html();
domUtils.hide(dom.byId("pager"));


});

//When features are associated with the map's info window update the sidebar with the new content.
connect.connect(popup, "onSetFeatures", function () {

displayPopupContent(popup.getSelectedFeature());
//dom.byId("featureCount").innerHTML = popup.features.length + " feature(s) selected";

//enable navigation if more than one feature is selected
//popup.features.length > 1 ? domUtils.show(dom.byId("pager")) : domUtils.hide(dom.byId("pager"));
});
}


function displayPopupContent(feature) {
var content = feature.getContent();
$("#leftPane").html(content);
}
}

function selectPrevious() {
map.infoWindow.selectPrevious();
}

function selectNext() {
map.infoWindow.selectNext();
}

});

Tags (1)
0 Kudos
0 Replies