var queryTaskBldg = new esri.tasks.QueryTask("http://mapmaker.millersville.edu/ArcGIS/rest/services/MU_Buildings/MapServer/0"); //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"); map.graphics.clear(); 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; attrib = graphic.attributes; bldgName = attrib.NAME; alert(bldgName); graphic.setSymbol(esriFillSym); graphic.setInfoTemplate(hoverTemplate); //Add graphic to the counties graphics layer. // map.graphics.add(graphic); graphicsLayer.add(graphic); } map.addLayer(graphicsLayer);
Solved! Go to Solution.
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
dojo.connect(queryTaskBldg, "onComplete", function(featureSet) ...with
queryTaskBldg.execute(parameters);. At the same time, I was experimenting with different JavaScript API and CSS version values. The mouse-based events worked as in the sample, once the function call worked.
dojo.connect(queryTaskBldg, "onComplete", function(featureSet) ...statement is the equivalent to a function call. What fires the dojo.connect (I assumed that "onComplete" meant that it executes when the map has drawn its initial contents)? And what does dojo.connect connect?
What fires the dojo.connect (I assumed that "onComplete" meant that it executes when the map has drawn its initial contents)? And what does dojo.connect connect?