delies

Draw either point or extent?

Discussion created by delies on Jun 9, 2011
Latest reply on Dec 12, 2011 by KG22
Hi all,

I'm trying to figure out how to use the Draw toolbar to allow a user to draw either a point or an extent.  I'm trying to use this for the identify tool.  I don't want the user to have to select either point or extent, I want the application to be intelligent enough to determine if the user has clicked a single point, or clicked and dragged the mouse to enclose an extent.  The problem I'm running into is if the Draw toolbar is in EXTENT mode, a single click starts drawing, and another single click finishes the drawing.  I want a single click to represent a point.  Is this possible?  Also, am I doing this the wrong way?  Is there a better way for the user to be able to identify from either a point or an extent?

This code seems like it would work, but since the Draw toolbar doesn't fire the "onDrawEnd" event on a single click if drawing an EXTENT, it doesn't.

var drawToolbar = new esri.toolbars.Draw(map);
    drawToolbar.activate(esri.toolbars.Draw.EXTENT);
    dojo.connect(drawToolbar, "onDrawEnd", function (geom) {
        if(geom.xmin == geom.xmax && geom.ymin == geom.ymax) {
            geom = new esri.geometry.Point(geom.xmin, geom.ymin, geom.spatialReference);
        }

        // execute an identifyTask using geom

    });

Thanks for your help.

Outcomes