ALKMaps.Layer.PointGrid
A point grid layer dynamically generates a regularly spaced grid of point features. This is
a specialty layer for cases where an application needs a regular grid of points. It can be
used, for example, in an editing environment to snap to a grid.
Create a new vector layer with the ALKMaps.Layer.PointGrid constructor.
// create a grid with points spaced at 10 map units
var points = new ALKMaps.Layer.PointGrid({dx: 10, dy: 10});
// create a grid with different x/y spacing rotated 15 degrees clockwise.
var points = new ALKMaps.Layer.PointGrid({dx: 5, dy: 10, rotation: 15});
Inherits from
dx
{Number} Point grid spacing in the x-axis direction (map units). Read-only. Use the
setSpacing
method to modify this value.
dy
{Number} Point grid spacing in the y-axis direction (map units). Read-only. Use the
setSpacing
method to modify this value.
ratio
{Number} Ratio of the desired grid size to the map viewport size. Default is 1.5.
Larger ratios mean the grid is recalculated less often while panning. The maxFeatures
setting has precedence when determining grid size. Read-only. Use the setRatio
method to modify this value.
maxFeatures
{Number} The maximum number of points to generate in the grid. Default is 250.
Read-only. Use the setMaxFeatures method to modify this value.
rotation
{Number} Grid rotation (in degrees clockwise from the positive x-axis). Default is 0.
Read-only. Use the setRotation method to modify this value.
origin
{ALKMaps.LonLat} Grid origin. The grid lattice will be
aligned with the origin. If not set at construction, the center of the map’s maximum
extent is used. Read-only. Use the setOrigin method to modify this value.
gridBounds
{ALKMaps.Bounds} Internally cached grid bounds (with optional
rotation applied).
ALKMaps.Layer.PointGrid
Creates a new point grid layer.
Parameters
| config |
{Object} An object containing all configuration properties for the
layer. The dx
and dy
properties are required to be set at construction. Any other layer properties may
be set in this object. |
setMap
The layer has been added to the map.
Parameters
removeMap
| removeMap: function( |
map |
) |
|
The layer has been removed from the map.
Parameters
setRatio
| setRatio: function( |
ratio |
) |
|
Set the grid ratio property
and update the grid. Can only be called after the layer has been added to a map with a
center/extent.
Parameters
setMaxFeatures
| setMaxFeatures: function(
|
maxFeatures |
) |
|
Set the grid maxFeatures
property and update the grid. Can only be called after the layer has been added to a map
with a center/extent.
Parameters
setSpacing
| setSpacing: function(
|
dx, |
|
dy |
) |
|
Set the grid dx and dy
properties and update the grid. If only one argument is provided, it will be set as dx and dy.
Can only be called after the layer has been added to a map with a center/extent.
Parameters
setOrigin
| setOrigin: function( |
origin |
) |
|
Set the grid origin
property and update the grid. Can only be called after the layer has been added to a map
with a center/extent.
Parameters
setRotation
| setRotation: function(
|
rotation |
) |
|
Set the grid rotation
property and update the grid. Rotation values are in degrees clockwise from the positive
x-axis (negative values for counter-clockwise rotation). Can only be called after the
layer has been added to a map with a center/extent.
Parameters
| rotation |
{Number} Degrees clockwise from the positive x-axis. |
onMoveEnd
Listener for map “moveend” events.
getViewBounds
| getViewBounds: function() |
Gets the (potentially rotated) view bounds for grid calculations.
Returns
{ALKMaps.Bounds}
updateGrid
| updateGrid: function(
|
force |
) |
|
Update the grid.
Parameters
| force |
{Boolean} Update the grid even if the previous bounds are still
valid. |
invalidBounds
| invalidBounds: function() |
Determine whether the previously generated point grid is invalid. This occurs when the map
bounds extends beyond the previously generated grid bounds.
Returns
{Boolean}