Select to view content in your preferred language

Add identify button to navigation widget

4316
6
Jump to solution
01-17-2013 09:20 AM
AnthonyGiles
Honored Contributor
All,

I am trying to add an icon to the navigation widget that opens up the identify widget, i.e:

[ATTACH=CONFIG]20812[/ATTACH]

I have managed to do this by adding the following to the navigation.mxml:

in the array collection for the images added:
<s:ArrayCollection>
<fx:Object action="pan" imageIcon="assets/images/i_pan.png" label="{LocalizationUtil.getDefaultString('panLabel')}"/>
<fx:Object action="zoomin" imageIcon="assets/images/i_zoomin.png" label="{LocalizationUtil.getDefaultString('zoomInLabel')}" visible="false"/>
<fx:Object action="zoomout" imageIcon="assets/images/i_zoomout.png" label="{LocalizationUtil.getDefaultString('zoomOutLabel')}"/>
<fx:Object action="identify" imageIcon="assets/images/i_identify.png" label="Identify" />
</s:ArrayCollection>


and then changed the doNavAction function to the following:

private function doNavAction(action:String, label:String):void
{
   var data:Object =
   {
       tool: action,
       status: label
   }
   if(data.tool == "identify")
  {
      AppEvent.dispatch(AppEvent.WIDGET_RUN, ViewerContainer.getInstance().widgetManager.getWidgetId("Identify"));
      AppEvent.dispatch(AppEvent.SET_MAP_NAVIGATION, {tool: "Pan",status: "Pan"});
   }
   else
  {
   AppEvent.dispatch(AppEvent.SET_MAP_NAVIGATION, data);
  }
}


This opens up the identify widget as expected and sets the map navigation back to pan, but unfortunatly it does not change the selected icon to the pan icon, how can I represent a mouse click on the pan icon using code,

Regards

Anthony
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Anthony,

   Try this:

private function doNavAction(action:String, label:String):void {
    var data:Object ={
        tool: action,
        status: label
    };
    if(data.tool == "identify"){
        AppEvent.dispatch(AppEvent.WIDGET_RUN, ViewerContainer.getInstance().widgetManager.getWidgetId("Identify"));
        AppEvent.dispatch(AppEvent.SET_MAP_NAVIGATION, {tool: "pan",status: "Pan"});
        var timeoutExample:uint = setTimeout(function():void{btnBar.selectedIndex = 0;},500);
   }else{
        AppEvent.dispatch(AppEvent.SET_MAP_NAVIGATION, data);
   };
}

View solution in original post

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Anthony,

   Try this:

private function doNavAction(action:String, label:String):void {
    var data:Object ={
        tool: action,
        status: label
    };
    if(data.tool == "identify"){
        AppEvent.dispatch(AppEvent.WIDGET_RUN, ViewerContainer.getInstance().widgetManager.getWidgetId("Identify"));
        AppEvent.dispatch(AppEvent.SET_MAP_NAVIGATION, {tool: "pan",status: "Pan"});
        var timeoutExample:uint = setTimeout(function():void{btnBar.selectedIndex = 0;},500);
   }else{
        AppEvent.dispatch(AppEvent.SET_MAP_NAVIGATION, data);
   };
}
0 Kudos
AnthonyGiles
Honored Contributor
Thanks Robert,

I'll give it a try when I'm in work tomorrow and yet you know how I get on

Regards

Anthony
0 Kudos
AnthonyGiles
Honored Contributor
Robert,

Works perfectly thank you

Regards

Anthony
0 Kudos
SaurabhGupta5
Frequent Contributor

Hi Robert,

I am trying to use same code but timer clock is not going away even after adding timer. What shall i do now?

Thanks

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Saurabh,

  Did you add the import for ViewerContainer?

import com.esri.viewer.ViewerContainer;

Also you need to add the following line to the  initButtonBar function

navAC.addItem({ label: "Identify", action: "identify", imageIcon: "assets/images/i_info.png" });

SaurabhGupta5
Frequent Contributor

Hi robert, yes i made it working now. thanks but i want to do something different instead of opening existing widget from this location. i have started new thread for same.

Help on identify toolhel

Thanks for your help

0 Kudos