MapGuide API Extensions v5.0

 

Object Snap Control

The Object Snap Control is an ActiveX component that is designed for implementation in MapGuide applications that require snapping capability. The control may be used in Redline applications that permit users to add or modify objects, enabling the snapping of vertices to existing map objects. The Control provides a set of public methods that enable the developer to:

  • establish the snapping parameters, including:
    • the vertices of an object to move: start node, end node, both endpoints, all vertices
    • the types of locations to snap to: endpoint, vertex, intersection
    • the maximum snap distance
    • whether all layers or selected layers can be snapped to
  • set the type of input and output coordinates: latitude/longitude or Mapping Coordinate System (MCS)
  • pass an MGPoint or an MGCollection (of MGPoints) to the control,
  • pause the MapGuide Viewer Control to avoid isBusy() conflicts.

When authoring maps, general or password access must be granted to the vertices of the layers which are to be eligible for snapping; refer to the layer's Security tab. If password access is granted, then the user will be prompted to enter the appropriate password when an object from the layer is selected for evaluation.

The control appears as a clickable button:

HgisSnap

The button may be sized through the BoxWidth and BoxHeight parameters while the label is set through the ButtonLabel parameter. Clicking on the button pulls up the Snap Menu:

Snap Menu

Function Description
Move Defines the types of vertices in the object passed to the control that are eligible to be relocated via snapping: None, Start Node Only, End Node Only, Both Endpoints, All Vertices.
To The type of location that a vertex may be snapped to: An Endpoint, Any Vertex, An Intersection. More than one option may be selected.
Distance The maximum distance that a vertex can be moved, expressed in Mapping Coordinate System units.
On The vertex may be snapped to Any Object or to an object on Selected Layers.
Layers A list of the layers in the map. Check the box of those layers that a vertex may be snapped to; this list is ignored if the vertex can be snapped to Any Object.

The snap parameters may also be established through the control's public methods.

Loading the Control

Instructions for implementing the control on web pages are provided with the Toolkit documentation.

Parameters

Name Description
Delim the delimiter used to separate items in a list, generally a forward slash (Default: "/") (refer to SnapParamLayer).
PauseLen the length of time in seconds to wait for the map prior to issuing an isBusy() call. Refer to the waitForMap() method. (Default: 2)
SnapParamMove Defines the types of vertices in the object passed to the control that are eligible to be relocated via snapping:
0 None (default)
1 start node only
2 end node only
3 both endpoints
4 all vertices
SnapParamTo Defines the type of location that a vertex may be snapped to:
1 endpoint
2 vertex (but not an endpoint)
4 intersection of a perpendicular to a polyline or polygon object
The values are additive: a value of 3 indicates that the new location can be an endpoint or a vertex of an existing object. The default value is 0.
SnapParamDistance The maximum distance that a vertex can be moved.
SnapParamObject Determines the layers that a vertex may be snapped to:
0 Any object (default)
1 Objects on selected layers only
If a value of one is passed, then the layer list must be established through SnapParamLayer.
SnapParamLayer A delimited list of the layers that may be snapped to; the items in the list are separated by Delim.
InputCoordinates The type of coordinates that will be passed to the control:
0 latitude/longitude (default)
1 Mapping Coordinate System (MCS)
OutputCoordinates The type of coordinates that will be output by the control:
0 latitude/longitude (default)
1 Mapping Coordinate System (MCS)
ButtonLabel The label to appear on the button (Default: "Hgis Snap" )
BoxWidth The width of the control in Twips (Default: 1500 Minimum: 200 )
BoxHeight The height of the control in Twips (Default: 500 Minimum: 50 )

Methods

A complete list of the public methods is provided with the Toolkit documentation.

 © 2002, Hunter GIS