Kelly,
Quick question:
Do i keep the identify tasks set up the way i have them and then use the promise?
Thanks. I will check out that example and let you know if i get it figured out. Thanks!
Robert,
There's only one info window so whichever identify finishes last will overwrite the first one with the content. I think instead you'll want to use dojo/promises/all to determine when both identify tasks have finished and then set the info window content. We have a sample in the help that shows how to work with multiple deferreds and dojo/promises/all here:
Manage results from multiple queries | ArcGIS API for JavaScript
I am using the deferred method for identify task. i have two services i would like to create tasks for and use info templates for each sub layer. The problem i am having is that it will only identify the last service in the code. in my main application it will identify the 1st layer i turn on that is in the first service. however, when i turn on layers in the second service it will no longer identify layers in the first service.
I created jsfiddle that is a simplified version of my application. Do you have any idea what i am doing wrong here?
Also, I am using this method so i can identify grids/rasters...
Edit fiddle - JSFiddle
parcelInfoTemplate = new esri.InfoTemplate(); parcelInfoTemplate.setTitle("Parcel Information"); parcelInfoTemplate.setContent(parcelSetWindowContent);
function doIdentify(event){ map.infoWindow.hide(); map.graphics.clear(); labelPt = event.mapPoint; parcelIdentifyParams.geometry = event.mapPoint; parcelIdentifyParams.mapExtent = map.extent; var deferred = parcelIdentifyTask.execute(parcelIdentifyParams); deferred.addCallback(function(response){ var feature = response[0].feature; showInfoWindow(feature,labelPt); }); } } function showInfoWindow (feature, labelPt) { feature.setInfoTemplate(parcelInfoTemplate); map.infoWindow.setTitle("Parcel Information"); map.infoWindow.setContent(feature.getContent()); map.infoWindow.show(labelPt); } function parcelSetWindowContent(graphic) { var nameTest1 = graphic.attributes.NAME1; var addressTest = graphic.attributes.SITEADDRES; var addressTest2 = graphic.attributes.SITEADDRESS;//very freaky that some seem to have one 's' and other two var legalTest1 = graphic.attributes.LEGAL1; var legalTest2 = graphic.attributes.LEGAL2; var legalTest3 = graphic.attributes.LEGAL3; var legalTest4 = graphic.attributes.LEGAL4; var fullLegalString; var twpRangeSecString; var twpTest = graphic.attributes.TOWNSHIP; var rngTest = graphic.attributes.RANGE; var secTest = graphic.attributes.SECTION; if (twpTest != 'undefined' && twpTest != 'Null') { twpRangeSecString = "TWP:" + graphic.attributes.TOWNSHIP; } if (rngTest != 'undefined' && rngTest != 'Null') { twpRangeSecString = twpRangeSecString + " RNG:" + graphic.attributes.RANGE; } if (secTest != 'undefined' && secTest != 'Null') { twpRangeSecString = twpRangeSecString + " SEC: " + graphic.attributes.SECTION; } var acreageTest = graphic.attributes.ACRES; var buildingNameTest = graphic.attributes.BUILDING_NAME; var bookTest = graphic.attributes.BOOK1; var pageTest = graphic.attributes.PAGE1; var initString = "";//used to see if there is really any content in the attribute values //There is problem with Null being detected as a 4 character length string instead of just nothing //checking to see if the value is longer than 4 characters because of this initTable = "<table id='infoWindowTable' data-dojo-type='dojox.grid.DataGrid' class='infoTable' ><tr><th></th><th></th></tr>"; if (nameTest1.length > 1) { initTable = initTable + "<tr><td><b>Owner:</b></td><td>" + nameTest1+ "</td></tr>"; initString = nameTest1; } if (buildingNameTest) { if (buildingNameTest.length > 4) { initTable = initTable + "<tr><td><b>Building:</b></td><td>" + buildingNameTest+ "</td></tr>"; initString = initString + buildingNameTest; } } if (addressTest) { if (addressTest.length > 4) { initTable = initTable + "<tr><td><b>Site Address:</b></td><td>" + addressTest + "</td></tr>"; initString = initString + addressTest; } } if (addressTest2) { if (addressTest2.length > 4) { initTable = initTable + "<tr><td><b>Site Address:</b></td><td>" + addressTest2 + "</td></tr>"; initString = initString + addressTest2; } } initTable = initTable + "</table><br><a id='btnZoom' onClick='zoomTo();'>Zoom To</a>"; //some counties provided so little information in a field that there wasn't enough information to put //in an infoWindow if (initString.length < 3) { initTable = "Limited data provided, see side panel."; } return initTable; }
One option might be to just add the layers you want to query to your application as feature layers in Selection only mode. When you add each feature layer define the info template for that layer. Note that in this example we don't have to query for attachment info because we've set showAttachments to true when defining the info template for the feature layer that has attachments. Then when you click the map you can use the feature layer's selectFeatures method to select the features of interest and display them in the popup. Here's a jsfiddle that shows this:http://jsfiddle.net/Wav9r/
Here's an example of using a DeferredList to await for the results of two different IdentifyTasks.
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.