Applying a custom VB action to a real-time layer

Conditions requises :

The custom VB layer action provided by Tracking Analyst is available if you install and license the ArcGIS Desktop VBA Resources for Developers software that is included in your ArcGIS Desktop media package. Installation and licensing information is available in the ArcGIS Desktop Installation Guide. Once installed, refer to the ArcGIS Desktop VBA Resources for Developers help system for instructions on using the Visual Basic Editor to create macros for ArcGIS Desktop.

Before following this procedure, you must have created a VB macro for use with this action using the Visual Basic Editor.

The custom VB layer action is different than the other layer actions because it can only be applied to real-time tracking layers. It is also different than service actions because it is defined for a tracking layer rather than a tracking service. VB actions are applied to real-time events as they are added to the tracking layer, but they are not applied to events already existing in the layer prior to triggering the action.

Learn more about custom VB actions for real-time tracking layers

Etapes :
  1. Using Visual Basic Editor, create the VB macro that you want to use on your real-time tracking layer.
  2. Right-click the tracking layer you want to apply the action to in the Table of Contents window and clickProperties on the context menu. The Layer Properties dialog box appears.

    Alternatively, you can double-click the tracking layer in the Table of Contents.

  3. Click the Actions tab on the Layer Properties form.
  4. Click the New Action button.
    Click the New Action... button to create a new action
  5. ChooseVisual Basic on the Type of Action to Create panel. The Visual Basic option will only be listed if you are working with a real-time tracking layer.
    Select the Visual Basic action
  6. Click in the text box and type a name for the action, then click OK to launch the action parameters form.
  7. On the Visual Basic Action Parameters dialog box, click the Project drop-down arrow and choose either Project or Normal.
    The Visual Basic Action Parameters dialog box
  8. A macro saved in the Normal folder affects all documents opened in ArcMap. A macro located in the Project folder only affects the current map document.

  9. Click the Module drop-down arrow and choose the module that contains your macro.
  10. The default module name in Visual Basic Editor is ThisDocument.

  11. Click the Macro drop-down arrow and choose the name of the macro you want to use.

    If you created a VB macro ahead of time and saved it in this module, it appears in the list.

  12. Set the trigger for your action. Click the button in the How the action will be triggered panel to the desired option below and follow further instructions to set your trigger:

    Always

    The action will always be triggered.

    Attribute Query

    The action will be triggered based on attribute criteria. Learn how to set an attribute trigger.

    Location Query

    The action will be triggered based on location criteria. Learn how to set a location trigger.

    Attribute AND Location Query

    The action will be triggered based on a combination of attribute and location criteria.

  13. When you have finished setting the trigger for the action, click OK to create the action.
  14. The new action appears in the list of layer actions. If other layer actions appear in the list, you can use the UP and DOWN ARROW buttons to put them in the order in which you want to them to be applied to the tracking layer. You can also enable or disable a layer action in the list by checking or unchecking its check box.
    The order of actions can be changed using the UP and DOWN ARROW buttons
  15. Click Apply or OK on the Layer Properties dialog box to apply all the changes.
AstuceAstuce :
VB macros used by this action must adhere to the format of your real-time tracking data. Some simple VB macros to get you started are here:

This macro displays the fifth field of an incoming data message on the ArcMap status bar. This macro will be run for all incoming events that meet the trigger criteria of the action.

Public Sub StatusBarMacro(ParamArray varArgs() As Variant)
    Application.StatusBar.Message(0) = varArgs(5)
End Sub

This macro displays the third field of an incoming data message in a message box. This macro will be run for all incoming events that meet the trigger criteria of the action.

Public Sub MessageBoxMacro(ParamArray varArgs() As Variant)
    MsgBox varArgs(3)
End Sub
AttentionAttention :

Use the custom VB action with caution. For instance, if you used the example message box macro on a real-time data feed with thousands of events, and all the records met the trigger criteria for the action, you would have to close a message box for every single event.

Rubriques connexes


7/10/2012