Basemap Gallery not opening

1518
1
07-20-2012 09:29 AM
CraigMcDade
Occasional Contributor III
I've been creating a mashup of code that started with the LocalGovernment ParkFinder and some of the custom stuff I have done and am almost finished with the application. I just can't seem to get the basemap gallery to open fully when I click on the icon. I have referenced js files and a config file that is unchanged from the ParkFinder Template. Can anybody check my code to see what I might be missing? The initial basemap loads so I know it is reading correctly from the config file, it just doesn't give me the option to change it...

Beating my head against the wall on this one.

dojo.require("esri.tasks.locator");
   dojo.require("dojo.number");
   dojo.require("dijit.form.Button");
   dojo.require("dijit.form.Textarea");
      dojo.require("dijit.layout.BorderContainer"); 
      dojo.require("dijit.layout.ContentPane"); 
      dojo.require("esri.map"); 
      dojo.require("esri.dijit.Popup"); 
      dojo.require("esri.tasks.query");
      dojo.require("esri.tasks.geometry");
      dojo.require("esri.layers.FeatureLayer");
      dojo.require("dijit.Dialog");
      dojo.require("dijit.TooltipDialog");
      dojo.require("dijit.form.ToggleButton");
      dojo.require("dojox.widget.Standby");
      dojo.require("esri.tasks.route"); 
 
      var baseMapLayerCollection; //variable to store basemap collection 
      var map, locator; 
      var resizeTimer; 
      var identifyTask,identifyParams;
   var defaultAddress; //variable for storing the default address 
   
      ;
      function init() { 
        var initExtent = new esri.geometry.Extent({
  "xmin":-9261027.70119949,
  "ymin":3341936.2768268585,
  "xmax":-9021474.054553657,
  "ymax":3479370.053683658,
  "spatialReference":{"wkid":102100}});

            esri.config.defaults.io.proxyUrl = "proxy.ashx";        //Setting to use proxy file
            esriConfig.defaults.io.alwaysUseProxy = false;
            esriConfig.defaults.io.timeout = 180000;    //ersi request timeout value

            dojo.connect(window, "onresize", function () {
                if (map) {
                    map.resize();
                    map.reposition();
                }
            });
  //Read Data from Config File
            dojo.xhrGet({
                url: "Config.txt",
                handleAs: "json",
                preventCache: true,
                load: function (responseObject, ioArgs) {
                    

                    
                   dojo.connect(dijit.byId('imgHelp'), "onClick", function () {
                        window.open(helpFileURL, "helpwindow");
                        dijit.byId('imgHelp').attr("checked", false);
                    });

                    helpFileURL = responseObject.HelpFileUrl;
                    dojo.byId('imgApp').src = responseObject.ApplicationImage;
                    dojo.byId('lblAppName').innerHTML = responseObject.ApplicationName;
                    baseMapLayerCollection = responseObject.BaseMapLayers;
                    CreateBaseMapComponent();
     dojo.connect(map, "onLoad", MapInitFunction);
     customMouseHandler.addEvent(dojo.byId('divContainer'), 'mouseleave', HideBaseMapWidget, false);
     customMouseHandler.addEvent(dojo.byId('divAppContent'), 'mouseleave', HideApplicationShareWidget, false);
                }  
   
   
  });
  
  
          
        //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",{ 
    logo:false,
          infoWindow:popup, 
          extent:initExtent
        }); 
 
         
        dojo.connect(map,"onLoad",mapReady); 
         
        //Add the imagery layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&f=typekeywords:service     
        var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer"); 
        map.addLayer(basemap); 
         
        var landBaseLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gisdev2/arcgis/rest/services/Basemaps/GeneralPurpose/MapServer",{opacity:0.75}); 
        map.addLayer(landBaseLayer); 
  
  var operationalLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gisdev2:6080/arcgis/rest/services/Dynamic/SurveyBenchmarks/MapServer", {"opacity":1});
        map.addLayer(operationalLayer);
      } 
       
      function mapReady(map){ 
 
       dojo.connect(map,"onClick",executeIdentifyTask); 
        
       //create identify tasks and setup parameters  
       identifyTask = new esri.tasks.IdentifyTask("http://gisdev2:6080/arcgis/rest/services/Dynamic/SurveyBenchmarks/MapServer"); 
        
       identifyParams = new esri.tasks.IdentifyParameters(); 
       identifyParams.tolerance = 5; 
       identifyParams.returnGeometry = true; 
       identifyParams.layerIds = [0,2]; 
       identifyParams.layerOption = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL; 
       identifyParams.width  = map.width; 
       identifyParams.height = map.height; 
        
        
       //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); 
         
       
      function locate() { 
        map.graphics.clear(); 
        var address = {"SingleLine":dojo.byId("address").value}; 
        locator.outSpatialReference= map.spatialReference; 
        var options = { 
          address:address, 
          outFields:["Loc_name"] 
        } 
        locator.addressToLocations(options); 
      } 
 
      function showResults(candidates) { 
        var candidate; 
        var symbol = new esri.symbol.SimpleMarkerSymbol(); 
        var infoTemplate = new esri.InfoTemplate("Location", "Address: ${address}<br />Score: ${score}<br />Source locator: ${locatorName}"); 
 
        symbol.setStyle(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE); 
        symbol.setColor(new dojo.Color([153,0,51,0.75])); 
 
        var geom; 
         
        dojo.every(candidates,function(candidate){ 
          console.log(candidate.score); 
          if (candidate.score > 80) { 
            console.log(candidate.location); 
            var attributes = { address: candidate.address, score:candidate.score, locatorName:candidate.attributes.Loc_name };    
            geom = candidate.location; 
            var graphic = new esri.Graphic(geom, symbol, attributes, infoTemplate); 
            //add a graphic to the map at the geocoded location 
            map.graphics.add(graphic); 
            //add a text symbol to the map listing the location of the matched address. 
            var displayText = candidate.address; 
            var font = new esri.symbol.Font("12pt",esri.symbol.Font.STYLE_NORMAL, esri.symbol.Font.VARIANT_NORMAL,esri.symbol.Font.WEIGHT_BOLD,"Helvetica"); 
            
            var textSymbol = new esri.symbol.TextSymbol(displayText,font,new dojo.Color("#666633")); 
            textSymbol.setOffset(0,8); 
            map.graphics.add(new esri.Graphic(geom, textSymbol)); 
            return false; //break out of loop after one candidate with score greater  than 80 is found. 
          } 
        }); 
        if(geom !== undefined){ 
          map.centerAndZoom(geom,16); 
        } 
 
      } 
   
   function executeIdentifyTask(evt) { 
        identifyParams.geometry = evt.mapPoint; 
        identifyParams.mapExtent = map.extent; 
        
        var deferred = identifyTask.execute(identifyParams); 
 
        deferred.addCallback(function(response) {      
          // response is an array of identify result objects     
          // Let's return an array of features. 
          return dojo.map(response, function(result) { 
            var feature = result.feature; 
            feature.attributes.layerName = result.layerName; 
            if(result.layerName === 'Control Corners'){ 
              console.log(feature.attributes.NAME); 
     var template = new esri.InfoTemplate("",
     "<b>Control Station:</b> <a target='_blank' href=http://gisdev2/surveybenchmarks/scans/${Corner Point Identifier}.pdf>${Corner Point Identifier}</a> <br><b>Point Type:</b> ${Corner Point Type} <br><b>Monument Type:</b> ${Monument Type} <br><b>Status:</b> ${Status}"

     
     );

    
              feature.setInfoTemplate(template); 
            } 
         
   return feature ; 
          }); 
        }); 
 
       
        // InfoWindow expects an array of features from each deferred 
        // object that you pass. If the response from the task execution  
        // above is not an array of features, then you need to add a callback 
        // like the one above to post-process the response and return an 
        // array of features. 
        map.infoWindow.setFeatures([ deferred ]); 
        map.infoWindow.show(evt.mapPoint); 
      } 
         
      dojo.addOnLoad(init);
0 Kudos
1 Reply
CraigMcDade
Occasional Contributor III
I cut out the html portion of the code bc it has been tested and works.
0 Kudos