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

Summary
ALKMaps.Layer.PointGridA point grid layer dynamically generates a regularly spaced grid of point features.
Properties
dx{Number} Point grid spacing in the x-axis direction (map units).
dy{Number} Point grid spacing in the y-axis direction (map units).
ratio{Number} Ratio of the desired grid size to the map viewport size.
maxFeatures{Number} The maximum number of points to generate in the grid.
rotation{Number} Grid rotation (in degrees clockwise from the positive x-axis).
origin{ALKMaps.LonLat} Grid origin.
gridBounds{ALKMaps.Bounds} Internally cached grid bounds (with optional rotation applied).
Constructor
ALKMaps.Layer.PointGridCreates a new point grid layer.
Functions
setMapThe layer has been added to the map.
removeMapThe layer has been removed from the map.
setRatioSet the grid ratio property and update the grid.
setMaxFeaturesSet the grid maxFeatures property and update the grid.
setSpacingSet the grid dx and dy properties and update the grid.
setOriginSet the grid origin property and update the grid.
getOriginGet the grid origin property.
setRotationSet the grid rotation property and update the grid.
onMoveEndListener for map “moveend” events.
getViewBoundsGets the (potentially rotated) view bounds for grid calculations.
updateGridUpdate the grid.
invalidBoundsDetermine whether the previously generated point grid is invalid.

Properties

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).

Constructor

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.

Functions

setMap

setMap: function(map)

The layer has been added to the map.

Parameters

map{ALKMaps.Map}

removeMap

removeMap: function(map)

The layer has been removed from the map.

Parameters

map{ALKMaps.Map}

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

ratio{Number}

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

maxFeatures{Number}

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

dx{Number}
dy{Number}

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

origin{ALKMaps.LonLat}

getOrigin

getOrigin: function()

Get the grid origin property.

Returns

{ALKMaps.LonLat} The grid origin.

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

onMoveEnd: function()

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}

This class represents a longitude and latitude pair
Instances of this class represent bounding boxes.
setMap: function(map)
The layer has been added to the map.
removeMap: function(map)
The layer has been removed from the map.
setRatio: function(ratio)
Set the grid ratio property and update the grid.
{Number} Ratio of the desired grid size to the map viewport size.
setMaxFeatures: function(maxFeatures)
Set the grid maxFeatures property and update the grid.
{Number} The maximum number of points to generate in the grid.
setSpacing: function(dx,
dy)
Set the grid dx and dy properties and update the grid.
{Number} Point grid spacing in the x-axis direction (map units).
{Number} Point grid spacing in the y-axis direction (map units).
setOrigin: function(origin)
Set the grid origin property and update the grid.
{ALKMaps.LonLat} Grid origin.
getOrigin: function()
Get the grid origin property.
setRotation: function(rotation)
Set the grid rotation property and update the grid.
{Number} Grid rotation (in degrees clockwise from the positive x-axis).
onMoveEnd: function()
Listener for map “moveend” events.
getViewBounds: function()
Gets the (potentially rotated) view bounds for grid calculations.
updateGrid: function(force)
Update the grid.
invalidBounds: function()
Determine whether the previously generated point grid is invalid.
Creates a new point grid layer.
Instances of ALKMaps.Layer.Vector are used to render vector data from a variety of sources.
Instances of ALKMaps.Map are interactive maps embedded in a web page.
Close