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

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

{OpenLayers.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.

Constructor

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

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

getOrigin

Returns

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.