Skip to main content

Pass additional parameter to a module

Comments

4 comments

  • Ryan Cooney

    Yes it is possible, but it is a bit complicated.

    Your LaunchUrl command likely has a parameter type of ESRI.ArcGIS.Client.Geometry.Geometry or ESRI.ArcGIS.Client.Geometry.MapPoint. If you change this type to:

    Geocortex.EssentialsSilverlightViewer.Infrastructure.Events.ToolEventPayload<ESRI.ArcGIS.Client.Draw,ESRI.ArcGIS.Client.DrawEventArgs>

    then rather than having the geometry passed to your command it will receive the entire tool event payload. This object provides access to both the geometry and the tool object with its child XML configuration.

    This allows you to configure your tool like this:

    <ToolName="OpenUrl" DisplayName="Open another site" DrawMode="Point" Command="LaunchUrl">

    <ConfigurationUrlTemplate="http://other.server.com/showinfo?x={0}&amp;y={1}" />

    </Tool>

    In your command implementation you can use payload.Args.Geometry to get the Geometry and payload.Tool.XmlConfiguration to get the tool's child config element. You'll have to parse the XML yourself.

    --Ryan

    0
  • Berend Veldkamp

    Ryan,

    Actually it isn't that hard once you know how to do it... The hardest part in this case is to find out about ToolEventPayLoad. Is this documented somewhere?

    Thanks a lot,

    Berend

    0
  • Berend Veldkamp

    I spoke too soon /customer/servlet/servlet.FileDownload?file=00P6000000e88GMEAY

    It works perfectly for a tool, but not for a menu item in the map's context menu.

    When the command parameter was a Geometry it did work, and the clicked coordinate was passed to the command, but now that I've changed it to ToolEventPayLoad, the parameter is empty:

     

    privatevoid ExecuteUrl(ToolEventPayload<Draw, DrawEventArgs> args)<p> </p> {

    //args = null here when

    And this is from my viewer.xml

    <MenuId="MapMenu"><p> </p>     <Items><p> </p>         <Item Text="Open cyclomedia" Command="LaunchUrl"><p> </p>             <Configuration UrlTemplate="http://my.server.com/page.html?X={0}&amp;Y={1}" />               <p> </p>         </Item>

    Can this also be done? Is there something like ItemEventPayLoad?

     

    0
  • Berend Veldkamp

    I figured it out. My module now listens to the map's MouseRightButtonDown event, so I can retrieve the location of the context menu. I use the item's CommandParameter value to store the urlTemplate. The only downside is that I now need two NamedCommands: one that can be called as a tool from a toolbar, and the other that can be called from the context menu. I think I can live with that.

    0

Please sign in to leave a comment.