AnsweredAssumed Answered

Draw graphics + Query

Question asked by jay.kapalczynski on Dec 8, 2014
Latest reply on Dec 12, 2014 by jay.kapalczynski

I am using the below code to draw graphics in the map.  Everything works great....

But I want to use those geometries to do spatial queries.  I need to call a specific Feature to get the geometry for the query making the Graphic far to general.   I am trying to select all the features from X Feature that are within the Geometry Drawn.  Noting that there might be other graphics in the map so thats why I am thinking I need to separate them and get them into a Feature that I can reference by itself.


I think I need to push the graphics drawn to a Feature?  Not sure how to do this.  Once I have the feature I can use its geometry for the query. 


Not sure if I am on the right path here...AND unsure how to convert the graphic to a feature so that its geometry can be used in a query....hope someone can help.



    // markerSymbol is used for point and multipoint, see for more examples

    var DrawmarkerSymbol = new SimpleMarkerSymbol();


        DrawmarkerSymbol.setColor(new Color("#00FFFF"));



  var DrawPicturemarkerSymbol = new esri.symbol.PictureMarkerSymbol({

  "angle": 0,

  "xoffset": 0,

  "yoffset": 12,

  "type": "esriPMS",

  "url": "",

  "contentType": "image/png",

  "width": 24,

  "height": 24



        // lineSymbol used for freehand polyline, polyline and line.

        var DrawlineSymbol = new CartographicLineSymbol(


          new Color([255,0,0]), 2,


          CartographicLineSymbol.JOIN_MITER, 5


        var DrawfillSymbol = new SimpleFillSymbol(


           new SimpleLineSymbol("solid", new Color([255,0,0]), 2),

           new Color([0,128,255,0.25])



        function initToolbar() {

          tb = new Draw(;

          tb.on("draw-end", addGraphic);

              // event delegation so a click handler is not

              // needed for each individual button

          on(dom.byId("infoShapefileCreate"), "click", function(evt) {

            if ( === "info" ) {



            var tool =;






  function addGraphic(evt) {

          //deactivate the toolbar and clear existing graphics




          // figure out which symbol to use

          var symbol;

          if ( evt.geometry.type === "point" || evt.geometry.type === "multipoint") {

            symbol = DrawPicturemarkerSymbol;

          } else if ( evt.geometry.type === "line" || evt.geometry.type === "polyline") {

            symbol = DrawlineSymbol;


          else {

            symbol = DrawfillSymbol;


 Graphic(evt.geometry, symbol));