AnsweredAssumed Answered

Cannot get my graphic layer to work

Question asked by AlexSabrina on Oct 15, 2014
Latest reply on Oct 15, 2014 by AlexSabrina

Hi all,

I am working on getting my web application to do something similar to the ArcGIS API for JavaScript Sandbox.

The goal is to create a popup infowindow when the user hovers a certain graphic on the map. This uses the GraphicLayer module. The problem here Is that I am already managing other graphic layers that I want to clear separately. In order to do . I use ="name";

I tried to replicate this for this info window when users hover but it seems like I am not getting any good results.


Here is the code infoTemplate on hover (starts when I setup a querytask):

dojo.connect(map, "onLoad", function () {
                         initialExtent = map.extent;
                         dojo.create("div", {
                             className: "esriSimpleSliderHomeButton",
                             title: 'Zoom to Full Extent',
                             onclick: function () {
                                 if (initialExtent === undefined) {
                                     initialExtent = map.extent;
                         }, dojo.query(".esriSimpleSliderIncrementButton")[0], "after");

                         //get rid of the javascript:void(0) statusbar message.
                         domAttr.remove(dojo.query(".action.zoomTo", map.infoWindow.domNode)[0], 'href');
                         domAttr.set(dojo.query(".action.zoomTo", map.infoWindow.domNode)[0], 'style', 'cursor:pointer;');

                         //add the overview map
                         domStyle.set(dojo.query(".draggable")[0], "display", "block");
                         overviewMapDijit = new esri.dijit.OverviewMap({
                             map: map,
                             width: 250,
                             height: 150,
                             attachTo: "top-right"
                         }, dojo.byId('overviewMapDiv'));
                         domStyle.set(dojo.query(".draggable")[0], "display", "none");
                         //Adding the two Graphics Layers here
                         var CoordGL = new GraphicsLayer();
                = 'coordinatesGL';
                         var DrawGL = new GraphicsLayer();
                = 'drawGL';
                         var TreatGraphicsLayer = new GraphicsLayer();
                = 'TreatGL';

                         //combine all the map add layers into this one
                         map.addLayers([CoordGL, DrawGL, dynaLayer1, TreatGL]);
                         //combine the two different map onLoad listeners you had into this one listener
                         selectionToolbar = new Draw(map);
                         selectionToolbar.on("draw-end", function (evt) {
                             //fixed issue with extra "solid" in the symbol
                             var symbol3 = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID, new SimpleLineSymbol("dash", new Color([255, 0, 0]), 2), new Color([255, 255, 0, 0.25]));
                             var gra = new Graphic(evt.geometry, symbol3);

                         var queryTask = new QueryTask("http://webgisdevint1/arcgis/rest/services/Alex_Try/Labeling/MapServer/1");

                         //build query filter
                         var query = new Query();
                         query.returnGeometry = true;
                         query.outFields = ["Proj_Name", "Treat_Name", "Treat_Num", "Treat_Cost", "AlexStatus"];
                         query.outSpatialReference = { "wkid": 102100 };
                         query.where = "Selection = 'All'";

                         var infoTemplate = new InfoTemplate();
                         var content = "<b>Status: </b>${AlexStatus}<br/>" +
                                       "<b>Treatment Name: </b>${Treat_Name}<br/>" +
                                       "<b>Treatment Number: </b>${Treat_Num}<br/>" +
                                       "<b>Treatment Cost: </b>${Treat_Cost}";

                         map.infoWindow.resize(245, 125);

                         //Can listen for complete event to process results
                         //or can use the callback option in the queryTask.execute method.
                         queryTask.on("complete", function (event) {
                             var highlightSymbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                               new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
                                 new Color([255, 0, 0]), 3), new Color([125, 125, 125, 0.35]));

                             var symbol5 = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
                               new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
                                 new Color([255, 255, 255, 0.35]), 1), new Color([125, 125, 125, 0.35]));

                             var features = event.featureSet.features;
                             //QueryTask returns a featureSet.
                             //Loop through features in the featureSet and add them to the map.
                             var featureCount = features.length;
                             for (var i = 0; i < featureCount; i++) {
                                 //Get the current feature from the featureSet.
                                 var graphic = features[i]; //Feature is a graphic
                             //listen for when the mouse-over event fires on the countiesGraphicsLayer
                             //when fired, create a new graphic with the geometry from event.graphic
                             //and add it to the maps graphics layer
                             TreatGraphicsLayer.on("mouse-over", function (event) {
                                 map.getLayer("TreatGL").clear();//use the maps graphics layer as the highlight layer
                                 var graphic = event.graphic;
                                 var highlightGraphic = new Graphic(graphic.geometry, highlightSymbol);

                             //listen for when mouse-out event is fired
                             //and then clear the highlight graphic
                             //and hide the info window
                   "mouse-out", function () {


Here is my script:

Cal Fire JQuery Template


What am I doing wrong here?

Thank you,