Select to view content in your preferred language

Interacting with the Map after selecting a button/tool

644
2
08-17-2010 12:21 AM
SimonEarnshaw
Occasional Contributor
Does anyone know how to wire up a dojo button (or toggle button) in a toolbar to a mouse click event on the map?

I want the user to have to select a tool/button before clicking on the map and NOT just have the map listen to any old mouse click event as this is too open i.e. I want to constrain the functionality to the selecting a tool from the UI.

Many thanks
0 Kudos
2 Replies
KeithSandell
Regular Contributor
Simon,

You don't want the user to have any control in the "map" itself without the user first clicking a button, i.e. no pan, no double-click zoom, no wheel zoom, etc.?

My first thought is that you should be able to use the activate() and deactivate() functions on the the dojo button tools to turn each other on and off similar to the "extent" buttons is in this sample:

http://help.arcgis.com/en/webapi/javascript/arcgis/demos/toolbar/toolbar_navigation.html

If you really want the map to be deaf to clicks you could deactivate() the map itself.

I would wire up the tools of the buttons to:

1) activate the tool and map on(button)Click
2) declare a variable to keep track of the use of the tool (only works if var use = 0)
3) set the variable after use (var use = 1)
4) deactivate the tool and map when the var use = 1;

Something along those lines

You'd have to work on all the if/esle logic, but basically the user would not be able to do anything unless he/she clicks a button each and everytime before interacting with the map.

Perhaps I have taken your want a tad to far, but you can really lock the app down its just going to take a lot of "getting" and "setting" of variables to keep track of the state of items.

I also like to control the users input, i.e. validate input and make them use the map the way I want so I don't have to account for too mnay stupid user issues.

But at a certain point of control you won't have to worry about the user anymore because they won't want to use the app.
0 Kudos
SimonEarnshaw
Occasional Contributor
Hey, thanks for that! I will check it out next week.
0 Kudos