ALKMaps.Control.FeatureSlicer

The FeatureSlicer control allows user to draw a straight line with two end markers.  Then User can move or stretch the line.  When mouse hovers over closer to the line, position values can be reported to the user.  This control exposes four key functions.  Define onLineDrawn function if user wants to know when a line has been drawn.  Define onLineStretched if user wants to know when a line has been stretched.  Define onLineMoved function if user wants to know when a line has been moved.  Define mouseoverLine function if user wants to know the line and mouse positions and the distance between the two when mouse hovers over the line or mouse is closer to the line within tolerance.toLine value.

Create a new control with the ALKMaps.Control.FeatureSlicer constructor.  User can override some default options such as styles when calling the control constructor.  It is only needed to add this control to the map control collection once.  Then user can start or restart this control by calling activate function.  After the control is activated, mouse up starts drawing the first marker, mouse move draws the line, and mouse up again finishes the drawing by adding the end marker.  User can move the line by dragging the line.  To stretch the line, user needs to drag any end marker of the line.  Calling deactivate function will stop the control and remove user drawings as well as perform necessary clean up.

Inherits From

var ctlSlicer = new ALKMaps.Control.FeatureSlicer({
    onLineDrawn: function(feature) {
        // Your code goes here.
    },
    onLineStretched: function(feature){
        // Your code goes here.
    },
    onLineMoved: function(feature) {
        // Your code goes here.
    },
    mouseoverLine: function(e) {
        // Your code goes here.
    }
  });

// A way to override some default options:
var ctlSlicer = new ALKMaps.Control.FeatureSlicer({
    tolerance: {toLine: 10, toLineEnd: 10},  // Both in pixels.
    nearTheLinePointerClass: "olDrawBox",
    overTheLineEndsPointerClass: "olControlFeatureSlicerOver",
    lineStyle: {strokeColor: "#ffff00", strokeWidth: 4},
    lineEndStyle: {graphicName: "star",
        pointRadius: 8,
        strokeColor: "#000000",
        fillColor: "#ffffff",
        strokeWidth: 1,
        fillOpacity: 1 },
    onLineDrawn: function(feature) {
        // Your code goes here.
    },
    onLineStretched: function(feature){
        // Your code goes here.
    },
    onLineMoved: function(feature) {
        // Your code goes here.
    },
    mouseoverLine: function(e) {
        // Your code goes here.
    }
  });


// User only needs to add this control the map control collection once.
// Then user can start or restart this control by calling this activate function.
ctlSlicer.activate();

// Stop the control.
// Calling deactivate function will remove your drawings and perform necessary clean up.
ctrlSlicer.deactivate();
Summary
ALKMaps.Control.FeatureSlicerThe FeatureSlicer control allows user to draw a straight line with two end markers.
Properties
citeCompliant{Boolean} If set to true, coordinates of features drawn in a map extent crossing the date line won’t exceed the world bounds.
documentDrag{Boolean} If set to true, mouse dragging will continue even if the mouse cursor leaves the map viewport.
layer{ALKMaps.Layer.Vector} This is a temporary layer for drawing the line and line end markers.
feature{ALKMaps.Feature.Vector}
dragCallbacks{Object} The functions that are sent to the drag handler for callback.
featureCallbacks{Object} The functions that are sent to the feature handler for callback.
lastPixel{ALKMaps.Pixel}
tolerance{Object} Used to add nearTheLinePointerClass to the viewport when mouse hovers over the line or within the tolerance distance to the line and not within toLineEnd distance when mouses moves closer to one of the line end.
nearTheLinePointerClass{String} Style class name when mouse hovers over the line or within tolerance distance to the line.
overTheLineEndsPointerClass{String} Style class name when mouse hovers over line end markers.
lineStyle{Object} Line style.
lineEndStyle{Object} Line end markers style.
onLineDrawn{Function} Define this function if you want to know when a line has been drawn.
onLineStretched{Function} Define this function if you want to know when a line has been stretched.
onLineMoved{Function} Define this function if you want to know when a line has been moved.
mouseoverLine{Function} Define this function if you want to know the line and mouse positions and the distance between the two when mouse hovers over the line or mouse is closer to the line within tolerance.toLine value.
enabled{Boolean} When the control is active, set this to false to suspend its activities temporarily.
Constructor
ALKMaps.Control.FeatureSlicerCreate a new control to create the line which can be moved, or stretched later.
Functions
destroyTake care of things that are not handled in superclass
activateActivate the control and the feature handler.
deactivateDeactivate the control and all handlers.

Properties

citeCompliant

{Boolean} If set to true, coordinates of features drawn in a map extent crossing the date line won’t exceed the world bounds.  Default is false.

documentDrag

{Boolean} If set to true, mouse dragging will continue even if the mouse cursor leaves the map viewport.  Default is false.

layer

{ALKMaps.Layer.Vector} This is a temporary layer for drawing the line and line end markers.  When the control is active, the layer will be added to the map.  It will be removed when the control is deactivated.

dragCallbacks

{Object} The functions that are sent to the drag handler for callback.

featureCallbacks

{Object} The functions that are sent to the feature handler for callback.

lastPixel

tolerance

{Object} Used to add nearTheLinePointerClass to the viewport when mouse hovers over the line or within the tolerance distance to the line and not within toLineEnd distance when mouses moves closer to one of the line end.

{
    toLine: 10, // Default 10 pixels.
    toLineEnd: 10, // Default 10 pixels.
}

nearTheLinePointerClass

{String} Style class name when mouse hovers over the line or within tolerance distance to the line.

.olControlFeatureSlicerLineOver {
    cursor: crosshair;
}

overTheLineEndsPointerClass

{String} Style class name when mouse hovers over line end markers.

.olControlFeatureSlicerLineEndOver {
    cursor: sw-resize;
}

lineStyle

{Object} Line style.

// Default line style
{
    strokeColor: "#ff0000",
    strokeWidth: 2
}

lineEndStyle

{Object} Line end markers style.

// Default line end markers style
{
    graphicName: "square",
    pointRadius: 4,
    strokeColor: "#000000",
    fillColor: "#ffffff",
    strokeWidth: 1,
    fillOpacity: 1
}

onLineDrawn

{Function} Define this function if you want to know when a line has been drawn.  The function should expect to receive one argument: the feature that has been drawn.

Parameters

feature{ALKMaps.Feature.Vector} The feature that has been drawn.  The feature.geometry.CLASS_Name is “ALKMaps.Geometry.LineString”.
feature: {
    geometry: {
        bounds: // ALKMaps.Bounds
        components: [
            // ALKMaps.Geometry.Point
        ]
    }
}

onLineStretched

{Function} Define this function if you want to know when a line has been stretched.  The function should expect to receive one argument: the feature that has been stretched.

Parameters

feature{ALKMaps.Feature.Vector} The feature that has been stretched.  The feature.geometry.CLASS_Name is “ALKMaps.Geometry.LineString>”.

onLineMoved

{Function} Define this function if you want to know when a line has been moved.  The function should expect to receive one argument: the feature that has been moved.

Parameters

feature{ALKMaps.Feature.Vector} The feature that has been stretched.  The feature.geometry.CLASS_Name is “ALKMaps.Geometry.LineString”.

mouseoverLine

{Function} Define this function if you want to know the line and mouse positions and the distance between the two when mouse hovers over the line or mouse is closer to the line within tolerance.toLine value.  The function should expect to receive one argument.

Parameters

dist{Object}
{
    x0: -10234174.979102623,    // closest x position on the line to the mouse
    x1: -10232777.849169,       // mouse x position
    y0: 3487289.012295028,      // closese y position on the line to the mouse
    y1: 3487362.9779974,        // mouse y position
    distance: 1399.086479297978 // distance between the mouse the point on the line
}

enabled

{Boolean} When the control is active, set this to false to suspend its activities temporarily.  Default is true.

Constructor

ALKMaps.Control.FeatureSlicer

Create a new control to create the line which can be moved, or stretched later.

Parameters

options{Object} Optional object whose properties will be set on the control.

Functions

destroy

destroy: function()

Take care of things that are not handled in superclass

activate

activate: function()

Activate the control and the feature handler.

Returns

{Boolean} Successfully activated the control and feature handler.

deactivate

deactivate: function()

Deactivate the control and all handlers.

Returns

{Boolean} Successfully deactivated the control.

Instances of ALKMaps.Layer.Vector are used to render vector data from a variety of sources.
Vector features use the ALKMaps.Geometry classes as geometry description.
This class represents a screen coordinate, in x and y coordinates
destroy: function()
Take care of things that are not handled in superclass
activate: function()
Activate the control and the feature handler.
deactivate: function()
Deactivate the control and all handlers.
{Function} Define this function if you want to know when a line has been drawn.
{Function} Define this function if you want to know when a line has been stretched.
{Function} Define this function if you want to know when a line has been moved.
{Function} Define this function if you want to know the line and mouse positions and the distance between the two when mouse hovers over the line or mouse is closer to the line within tolerance.toLine value.
{Object} Used to add nearTheLinePointerClass to the viewport when mouse hovers over the line or within the tolerance distance to the line and not within toLineEnd distance when mouses moves closer to one of the line end.
Create a new control to create the line which can be moved, or stretched later.
Controls affect the display or behavior of the map.
Close