Pitney Bowes MapXtreme User Manual

Page 89

Advertising
background image

Chapter 5: Web Applications, Controls, and Tools

Creating a Custom Tool

MapXtreme v7.1

89

Developer Guide

1. Drag the generic WebTool from the MapXtreme toolbox onto your web form. You can also use

one of the existing map tools if you want to extend the existing behavior.

2. In the WebTool property page, set the properties for MapControlID, InActive/ActiveImageUrl and

CursorImageUrl.

3. Set the appropriate ClientInteraction property by selecting from the drop-down list.

The built-in interactions include mouse operations for clicking and dragging, drawing lines,
polygons, rectangles and radii, which will cover the needs of most web application. See the
Interaction.js in the MapXtremeWebResources folder in your project.

4. Set the appropriate ClientCommand property by selecting from the drop-down list.

The built-in client commands for mapping, panning, zooming, etc., create the URL request that is
sent to the server. For a description of these commands, see the Command.js in the
MapXtremeWebResources folder in your project.
If one of the built-in commands does not meet your needs, either modify the existing
Command.js or write your own. The custom command takes the name of the interaction from
step 3 as input. See CustomCommand.js in the CustomToolsCS or CustomToolsVB sample for
an example of how to get multiple responses from the server with a single click.

5. Register the JavaScript manually in your .aspx page. Insert the following line within the web

page body.

<script language="javascript" src="CustomCommand.js"

type="text/javascript"></script>

6. Create a new server command class that derives from

MapInfo.WebControls.MapBaseCommand. Include code that carries out the behavior that the
client command requested. Alternatively, you can extend an existing server command class.

7. In the server command class, assign the name of the server command in the constructor.

namespace ToolsSample
{
public class AddPinPointCommand : MapInfo.WebControls.MapBaseCommand
{

/// <summary>
/// Constructor for this command, sets the name of the command
/// </summary>
/// <remarks>None</remarks>
public AddPinPointCommand()
{

Name = "AddPinPointCommand";

}

8. In the server command class, override the Process() method by adding code that carries out the

business logic for the command.

public override void Process()

{

// Your code here.....

}

9. In the Page_Load method of the webform1.aspx, add your server command to the collection of

commands in the MapControlModel.

Advertising