AnsweredAssumed Answered

Problem with adapting Hover sample: QueryTask does not execute

Question asked by cgeiger on Mar 8, 2013
Latest reply on Mar 12, 2013 by cgeiger
I am trying to adapt the JavaScript sample "Load query results and show on hover" to a map of my university campus which will let users hover over a building, highlight the building and produce a tooltip-type InfoWindow showing the building name (about 75 buildings on campus).  I have a tiled base map of the campus for the background, and created an additional map service (not tiled) of the buildings alone. It seems to me that the graphics layer approach of the sample should be fine; we don't have ArcSDE (yet) for the feature layer approach.  Everything performs just fine except for the QueryTask, about halfway down in the code snippet below.  You'll notice a couple of javascript alerts, which never fire.  I tried tracing it in Firebug, but get lost in the dojo part of the trail.  Any help will be appreciated.

      var queryTaskBldg = new esri.tasks.QueryTask("");          //build query filter       var queryBldg = new esri.tasks.Query();         queryBldg.returnGeometry = true;         queryBldg.outFields = ["NAME"];         queryBldg.outSpatialReference = spaRef;  //  {"wkid":2272}         queryBldg.where = "USE = 'Academic'";  //  I don't want this, but I am trying to imitate the sample        sHover = "${NAME}";       hoverTemplate = new esri.InfoTemplate();         hoverTemplate.setTitle(sHover);         hoverTemplate.setContent("Name : ${NAME}");        map.infoWindow.resize(200,100);        dojo.connect(queryTaskBldg, "onComplete", function(featureSet) {  //THIS IS WHERE IT FAILS         alert("Hi");;         var features = featureSet.features;         var graphic, attributes, bldgName;           //QueryTask returns a featureSet.  Loop through features in the featureSet and add them to the map.         for (var i=0, il=features.length; i<il; i++) {           //Get the current feature from the featureSet.           //Feature is a graphic           graphic = features[i];           attrib = graphic.attributes;           bldgName = attrib.NAME;           alert(bldgName);           graphic.setSymbol(esriFillSym);           graphic.setInfoTemplate(hoverTemplate);            //Add graphic to the counties graphics layer. //;            graphicsLayer.add(graphic);         }         map.addLayer(graphicsLayer);