the ongoing battle between popup and onclick

Discussion created by empicard on Feb 27, 2012
Latest reply on Feb 27, 2012 by DSwingley-esristaff
sorry to post such a huge chunk of my code, but I'm at a loss.

"district layer" turns on at about 1:4,000,000. if I click before I zoomed in that far (and its not turned on yet), it enters the OnClick and completes the function and the rendering, with no popup.
I cannot see it change color until you zoom in.

If you zoom in to 4,000,000, the layer becomes visible.  If you click again, I get a popup window, but the polygon doesnt change color, and I never see the  alerts I have set up
("click", "DQF", "imback")

I *WOULD LIKE* to see the polygon change color, and get a popup at the same time.  I'm using the local compact js build 2.6.

PS - please be kind.  I'm sure its a mess.  I'm new to javasript. :)

      var map, startExtent;
      var districtLayer, divisionLayer, streetMapLayer, nozipsLayer, zipslayer;
      var selectingTool, radioOne;
      var menu; //SLIDEINMENU    

      function init() {
        //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"));        

        //Create map and add the ArcGIS Online imagery layer

        startExtent = new esri.geometry.Extent({"xmin":-17497000,"ymin":2165000,"xmax":-4132000,"ymax":6969000,"spatialReference":{"wkid":102100}});

        map = new esri.Map("map", { 
          logo: false,
          extent: startExtent,

        var streetMapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");

         dojo.connect(map, 'onLoad', function(evt) {
           var distcontent = "<b>District</b>: ${NEW_DIST} <br/><b>Division</b>: ${NEW_DIVCOD}";
           var distinfoTemplate = new esri.InfoTemplate("District Data", distcontent);
           var districtLayer = new esri.layers.FeatureLayer("http://AGSserver/ArcGIS/rest/services/IndivTerritoriesOnly/districts/FeatureServer/0",{
              mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
              outFields: ["NEW_DIST","NEW_DIVCOD"],
              infoTemplate: distinfoTemplate
           var distRend = new esri.renderer.SimpleRenderer( new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([245,0,0,0])));
           districtLayer.setSelectionSymbol(new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([245,0,0,.60])));  

           dojo.connect(map, 'onClick', function(evt){
             switch (dojo.byId("radioOne").value) {
               case "districtLayer":
                 districtQueryFunction(evt, districtLayer);
                 alert("im back");
               case "division":
                 divisionQueryFunction(evt, divisionLayer);


        });    //end of OnLoad...    

       };   //end of init

        function loaded() {
         document.addEventListener('touchmove', function(e){ e.preventDefault(); e.stopPropagation(); });
         menu = new slideInMenu('slidedownmenu', true);
        }; //SLIDEINMENU
        document.addEventListener('DOMContentLoaded', loaded);


      function districtQueryFunction(evt, districtLayer){
        alert ("DQF");
            var query = new esri.tasks.Query();
            query.geometry = evt.mapPoint;
            districtLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);