ArcGIS API for Javascript Not Adding Layer and/or Graphic during mouse event handler?

المشرف العام

Administrator
طاقم الإدارة
I am trying to add a graphic to my graphics layer during a map mouse event. In the javascript console, I can see that my graphic object is created and no error is thrown when I add the graphic to my graphics layer. However, when I try to add the graphics layer to the map, nothing happens. Same thing happens when I try to do a map.graphics.add(graphic) function. Has anyone else run into this? Or is there a workaround for this issue?

Here's my code:

app.map.on("mouse-drag",function(evt){ if(evt.ctrlKey){ //control key must be pressed var polygonSymbol = new SimpleFillSymbol(); //create the symbol for the graphic var polygon = new Polygon(makeArc(evt)); //create the polygon the the returned geometry from makeArc() var graphic = new Graphic(polygon,polygonSymbol); //create the graphic objet console.log(graphic); gLayer.add(graphic); //add the graphic to the graphic layer app.map.addLayer(gLayer); //add the graphic layer to the map } });Also, I know that it is not being added because I can't see the html inside the map div after the event occurs, which I usually can when I add a graphic or layer.



أكثر...
 
أعلى