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.

Create a new vector layer with the OpenLayers.Layer.PointGrid constructor.

// create a grid with points spaced at 10 map units
var points = new OpenLayers.Layer.PointGrid({dx: 10, dy: 10});

// create a grid with different x/y spacing rotated 15 degrees clockwise.
var points = new OpenLayers.Layer.PointGrid({dx: 5, dy: 10, rotation: 15});

Inherits from

Summary
OpenLayers. Layer. PointGrid A 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 {OpenLayers.LonLat} Grid origin.
Constructor
OpenLayers. Layer. PointGrid Creates a new point grid layer.
Functions
setRatio Set the grid ratio property and update the grid.
setMaxFeatures Set the grid maxFeatures property and update the grid.
setSpacing Set the grid dx and dy properties and update the grid.
setOrigin Set the grid origin property and update the grid.
getOrigin Get the grid origin property.
setRotation Set the grid rotation property and update the 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

origin {OpenLayers.LonLat}

getOrigin

getOrigin: function()

Get the grid origin property.

Returns

{OpenLayers.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.
This class represents a longitude and latitude pair
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.
{OpenLayers.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).
Creates a new point grid layer.
Instances of OpenLayers.Layer.Vector are used to render vector data from a variety of sources.
Close