Select to view content in your preferred language

How to deactivate toolbar (esri.toolbars.draw) when navigation tool is clicked?

1846
2
10-19-2011 10:02 AM
SanajyJadhav
Deactivated User
Hi,

I have Navigation toolbar and normal toolbar (esri.toolbars.draw) to draw various shapes of graphics.When I click normal toolbar, I can draw my graphics, that is fine.However,if immediately after this, I click on any navigation tool (say zoom in), previously draw graphics is also drawn along with zoom in rectanlge.So map is zoomed in but graphics is also drawn.I have to deactivate the normal toolbar (the one that draws graphics.)

Since, nav toolbar tools are mere calls to API methods, how can a catch the click event of any tool on the navigation toolbar? In this event, I would call deactivate method.

I am very new to JS API, so any help is much appreciated.

Regards,
Sanjay.
0 Kudos
2 Replies
HemingZhu
Frequent Contributor
Hi, 

I have Navigation toolbar and normal toolbar (esri.toolbars.draw) to draw various shapes of graphics.When I click normal toolbar, I can draw my graphics, that is fine.However,if immediately after this, I click on any navigation tool (say zoom in), previously draw graphics is also drawn along with zoom in rectanlge.So map is zoomed in but graphics is also drawn.I have to deactivate the normal toolbar (the one that draws graphics.) 

Since, nav toolbar tools are mere calls to API methods, how can a catch the click event of any tool on the navigation toolbar? In this event, I would call deactivate method.  

I am very new to JS API, so any help is much appreciated. 

Regards, 
Sanjay.

When you activate the draw toolbar, API will automatically deactivate the map navigation. It does not, however, do the opposite way. But you can easily add one statement to deactivate your drawing toolbar when you activate your navigation bar.
For example, in http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/toolbar_navigation.html. you could add drawingtoolbar.deactivate() in onClick:function(){navToolbar.activate(esri.toolbars.Navigation.ZOOM_IN);drawingtoolbar.deactivate();}
0 Kudos
SanajyJadhav
Deactivated User
Thanks Heming for the reply.

This should work for me.I will try it.
0 Kudos