AnsweredAssumed Answered

How to get JSON returns as separate panels in an InfoWindow?

Question asked by minnag on Nov 22, 2017
Latest reply on Nov 27, 2017 by minnag

I have a widget (CMV viewer) where a click on the map sends an xy request to a web data service and gets multiple returns back in JSON format. There are no map layers for this. There could be a varying number of JSON returns, from 1 to 10, all with the same set of attributes. I am using esriRequest to process all the requests until all are done. Then they are pushed to an array. Using a for loop, I parse each return and display the results in an InfoWindow. This all works fine. However, all the returns are all just stacked in the one infoWindow, and with multiple returns, I would like to show each set of attributes on its own panel in the InfoWindow with the little "next" and "prev" arrow buttons on the top title bar so users can tab through the results, just like they can do with multiple results on the Identify window.

 

Is this even possible???? Bascially I just have an array of JSON responses, no "features" and no "layers."

 

Here's some of what I've been attempting -- the error I currently get with this is "subarray.setInfoTemplate is not a function." 

 

Any ideas?? 

 

Thank you!!!

 

Robert Scheitlin, GISP

Tyler Waring

 

 

*********************************************

 

var requestHandle = esriRequest({
url: rpourl,
handleAs: "json",
});

 

requestGroup.push(requestHandle);

 

all(requestGroup).then(lang.hitch(this, function(rpreturns){

 

for(var i = 0; i < rpreturns.length; i++) {
var subarray = rpreturns[i];
var rpostring = JSON.stringify(subarray).replace(/]|[[]/g, '');    // I'm not using this here in this example, not sure if I should
var mydata = JSON.parse(rpostring);  //same here

var infoTemplate = new InfoTemplate();

infoTemplate.setTitle("My new Title");
infoTemplate.setContent("<b>RouteID: </b>" + rpreturns.RouteId + "<br/>" +
"<b>Mile: </b>" + rpreturns.Mile + "<br/><br/>");

subarray.setInfoTemplate(infoTemplate);
this.map.infoWindow.setFeatures(rpreturns);
this.map.infoWindow.show(evt.mapPoint);

Outcomes