graphics from parent window do not display in child window

579
3
12-07-2012 11:07 AM
deleted-user-ugCMpXci8bn5
New Contributor III
Hello, I posted this question on StackOverflow but did not get any response, maybe someone here can help? Thanks!

My webapp allows the user to zoom to a map extent, then create a new window with a new map drawn to the zoomed extent of the parent window map. The parent map contains graphics, which should also be passed and added to the child window map. My problem is that the graphics do not draw in the child window until I refresh the page. Once I manually refresh, all the graphics are there in the right place. I have tried various ways of forcing a refresh of the map or layer using javascript but nothing has worked. Also, when I refresh the child page, the graphics disappear from the parent page. If anyone has ideas I would appreciate it, thanks. Code below (note, this code is for the child window, 'window.opener' refers to the parent window):

 function drawCrosswalks()   
{
    updateLayerVisibility();
    var locCrosswalkArray = [];
    for (var i=0, l=window.opener.globalCrosswalkArray.length; i<l; i++)
    {
        locCrosswalkArray = window.opener.globalCrosswalkArray;;
                    // globalCrosswalkArray is a graphics array from the parent page)
    }

    if (locCrosswalkArray.length > 0) 
    {            
        for (var i = 0, il = window.opener.globalCrosswalkArray.length; i < il; i++) 
        {
            var symbol;
            var  crossWalkG =  window.opener.globalCrosswalkArray.feature;
            symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, 
            new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
                new dojo.Color([50, 205, 50]), 3), new dojo.Color([0, 0, 255, 0])); 
            crossWalkG.setSymbol(symbol);              
            printMap.graphics.add(crossWalkG);
        }

    } // end if

    printMap.resize();       
    printMap.setExtent(printMap.extent) ;
    schoolSafetyLayer.refresh(); // none of this worked

 } // end func




The child window is created from the parent with this code:

\function printWindow()
 {
  newWindow = window.open ("blank.html");
  if(newWindow.pageLoadStatus==true) {
   console.log("true"); }

  printXMax = map.extent.xmax;
  printXMin = map.extent.xmin;
  printYMax = map.extent.ymax;
  printYMin = map.extent.ymin;
  
 }
0 Kudos
3 Replies
deleted-user-ugCMpXci8bn5
New Contributor III
Hello, I still haven't found a solution for this...am thinking I may need to use a deferred callback? Any ideas would be appreciated, thanks!
0 Kudos
Udaya_BhaskerCheerala
New Contributor
Hi,

I also having the same requirement. did you get any solution? if yes, please share it.

Thanks,
Uday
0 Kudos
deleted-user-ugCMpXci8bn5
New Contributor III
Not exactly, I just ended up re-running my query and creating the graphics independently in the new page.  I passed only the extent using window.opener.
0 Kudos