mcdade31

Map requires a refresh to initialize

Discussion created by mcdade31 on Oct 15, 2012
Latest reply on Oct 17, 2012 by mcdade31
When I launch my application in a browser it shows the shell (header and other panes) but it does not show the map itself. When I refrefresh the browser everything draws...

Any idea what might be causing this. Happens in all browsers.

Here is my init function:

function init() {

 dojo.connect(dijit.byId("gridParcel"), "onRowClick", onRowClickHandler);
    
  //Slash Screen Message 
    var myMessage = "<snip>;
     dojo.byId('divLoadMessage').innerHTML = myMessage;
     dijit.byId('dialogLoadMessage').show();
   
    var initExtent = new esri.geometry.Extent({"xmin":-9199621.530456403,
    "ymin":3365235.5214724857,
    "xmax":-9077475.159256855,
    "ymax":3443965.6606061114,
    "spatialReference":{"wkid":102100}});  
    
  //setup the popup window 
        var popup = new esri.dijit.Popup({
          fillSymbol: new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.25]))
        }, dojo.create("div"));
        
    map = new esri.Map("map", {
     infoWindow:popup,
     extent:initExtent, 
     logo:false
     });
    
   dojo.connect(map,"onLoad",mapReady);
   
    //Set The Initial Basemap
    var initBasemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer");
        map.addLayer(initBasemap);
    
        createBasemapGallery();
    
    //Create Find Task using the URL of the map service to search
        findTaskParcel = new esri.tasks.FindTask("http://gisprod2/arcgis/rest/services/Dynamic/ParcelsTestSDE/MapServer");

        //Create the find parameters
        findParamsParcel = new esri.tasks.FindParameters();
        findParamsParcel.returnGeometry = true;
        findParamsParcel.layerIds = [0];
        findParamsParcel.searchFields = ["PARCELID", "SITEADDRESS"];
        findParamsParcel.outSpatialReference = map.spatialReference;

        //Create Find Task using the URL of the map service to search
        findTaskYear = new esri.tasks.FindTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/TaxParcel/TaxParcelQuery/MapServer/");

        //Create the find parameters
        findParamsYear = new esri.tasks.FindParameters();
        findParamsYear.returnGeometry = true;
        findParamsYear.layerIds = [0];
        findParamsYear.searchFields = ["RESYRBLT"];
        findParamsYear.outSpatialReference = map.spatialReference;
        
    //resize the map when the browser resizes
       dojo.connect(map, 'onLoad', function (theMap) {
          //resize the map when the browser resizes
          dojo.connect(dijit.byId('map'), 'resize', map, map.resize);
        });
      
    locator = new esri.tasks.Locator("http://tasks.arcgis.com/ArcGIS/rest/services/WorldLocator/GeocodeServer");
        dojo.connect(locator, "onAddressToLocationsComplete", showResults);
        
        map.infoWindow.resize(300,125);
    
    //parcellayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gisprod2/arcgis/rest/services/Dynamic/ParcelsTestSDE/MapServer");
    layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gisprod2/arcgis/rest/services/Dynamic/Zoning/MapServer");
    
  
  //Add the Legend
    legendLayers.push({layer:layer,title:''});
    dojo.connect(map,'onLayersAddResult',function(results){
          var legend = new esri.dijit.Legend({
            map:map,
            layerInfos:legendLayers
          },"legendDiv");
          legend.startup();
        });
    map.addLayers([layer]);
  
        if (layer.loaded) {
          buildLayerList(layer);
        }
        else {
          dojo.connect(layer, "onLoad", buildLayerList);
        }
   }

Outcomes