AnsweredAssumed Answered

InfoWindow InnerHTML Issues

Question asked by lloydbronn on Apr 10, 2017
Latest reply on Apr 11, 2017 by lloydbronn

I'm using this example to draw a polygon which will kick off a GP tool that generates a report based on the area of polygon. I've got it working but I'm having an issue with an interval function. I have another script that makes reports based on clicked countries. When a GP tool link is clicked in the infoWindow, it says "Generating Report..." dot dot dot, etc until the report is finished. I'm trying to use this same method, but this time there is no link to click on. The infoWindow will pop up once the polygon is drawn and the GP tool kicks off. I just can't get this to work. When I run this, the infoWindow pops up but immediately disappears. I can see the text "generating report..." hovering over the map. 

 

function generateReport(evtObj) {
           
        var geometry = evtObj.geometry;

          var mp = webMercatorUtils.webMercatorToGeographic(geometry);     
          var extent = mp.getExtent();
          var center = geometry.getCentroid();
          var xmin = extent.xmin.toFixed(2); //west_lon
          var ymin = extent.ymin.toFixed(2); //south_lat
          var xmax = extent.xmax.toFixed(2); //east_lon
          var ymax = extent.ymax.toFixed(2); //north_lat
          
          var location = prompt("Please Enter a Region Name","");          
            
                var taskParams = {
                "region_name": location,
                    "west_lon": xmin,
                    "south_lat": ymin,
                    "east_lon": xmax,
                    "north_lat": ymax
              };
          
          
          
        var symbol = new SimpleFillSymbol("none", new SimpleLineSymbol("dashdot", new Color([255,0,0]), 2), new Color([255,255,0,0.25]));
        var graphic = new Graphic(geometry,symbol);

        map.graphics.add(graphic);
        toolbar.deactivate();

        var features= [];
        features.push(graphic);
          
          gpReport.execute(taskParams);
          map.graphics.clear();
          
          map.infoWindow.resize(256,256);
          map.infoWindow.show(center,map.getInfoWindowAnchor(center));
          map.infoWindow.setTitle("Forecast Report");
          map.infoWindow.setContent("Forecast Analysis Report")
          
           var dots = window.setInterval( function() {
           var wait = map.infoWindow.domNode,
               msg = "Generating Report",
               msgLen = msg.length;
                    if (wait.innerHTML.length > (msgLen + 2))
                         wait.innerHTML = msg;
                    else
                         wait.innerHTML += ".";
                    }, 400);
                    
          }

 

In my other script var wait = document.getElementById("reportLink"); I've tried giving the infoWindow div an ID, but that doesn't work. I've also tried to use map.infoWindow.innerHTML;

Outcomes