query activation with a button

536
2
12-07-2010 09:18 AM
NatalieO_Toole
New Contributor
Hi,

How do I add a button to my javascript api website, that when the user clicks it, the query functionality is activated, and the user can click on a polygon to retrieve a list of results. I already know how to create the query functionality, but just not how to activate it with a button.

Help please!

Nat
0 Kudos
2 Replies
KenDoman
Occasional Contributor II
It will look something like this:

var queryClick

function queryTurnOn() {
   queryClick = dojo.connect(map, "onClick", queryThis);
}

function queryThis(evt) {
  /* throw some code in here */
}

function queryTurnOff() {
    dojo.disconnect(queryClick);
}
Read this for more information:
http://help.arcgis.com/en/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_events.htm
0 Kudos
HemingZhu
Occasional Contributor III
Hi,

How do I add a button to my javascript api website, that when the user clicks it, the query functionality is activated, and the user can click on a polygon to retrieve a list of results. I already know how to create the query functionality, but just not how to activate it with a button.

Help please!

Nat



Create a drawtoolbar and activate it when user click on button. Then when use click on a polygon ( i assume the polygon is on the graphic layer), you can start do the query... Code should something like this:
       dojo.connect(map.graphics, "onclick", function(evt){
              var polygon =evt.graphic.geometry;
              //you query function go here
       });

       drawToolbar = new esri.toolbars.Draw(map);
       drawToolbar.activate(esri.toolbars.Draw.POINT);
       dojo.connect(drawToolbar, "onDrawEnd", function(point){
             drawToolbar.deactivate();
             // when you draw a point, it with fire the graphic layer's onclick event...
       });

       let me know if you have any quetions on my answer...
0 Kudos