Class: GridReference

ol.control. GridReference

Draw a grid reference on the map and add an index.


new GridReference( [Control])

Parameters:
Name Type Argument Description
Control Object <optional>

options.

options.style ol.style.Style

Style to use for drawing the grid (stroke and text), default black.

options.maxResolution number

max resolution to display the graticule

options.extent ol.extent

extent of the grid, required

options.size ol.size

number of lines and cols, required

options.margin number

margin to display text (in px), default 0px

options.source ol.source.Vector

source to use for the index, default none (use setIndex to reset the index)

options.property string | function

a property to display in the index or a function that takes a feature and return the name to display in the index, default 'name'.

options.sortFeatures function | undefined

sort function to sort 2 features in the index, default sort on property option

options.indexTitle function | undefined

a function that takes a feature and return the title to display in the index, default the first letter of property option

options.filterLabel string

label to display in the search bar, default 'filter'

Fires:
  • event:select

Extends

Methods


getCanvas()

Get canvas overlay

Inherited From:
Overrides:

getFeatureName(f)

Returns the text to be displayed in the index

Parameters:
Name Type Description
f ol.Feature

the feature

Returns:

the text to be displayed in the index

Type
string

getFill()

Get fill

Inherited From:
Overrides:

getHIndex(index)

Get horizontal index (A,B,C...)

Parameters:
Name Type Description
index number
Returns:
Type
string

getReference(coords)

Get reference for a coord

Parameters:
Name Type Description
coords ol.coordinate
Returns:

the reference

Type
string

getStroke()

Get stroke

Inherited From:
Overrides:

getStyle()

Get style

Inherited From:
Overrides:

getTextFill()

Get text fill

Inherited From:
Overrides:

getTextFont()

Get text font

Inherited From:
Overrides:

getTextStroke()

Get stroke

Inherited From:
Overrides:

getVIndex(index)

Get vertical index (0,1,2,3...)

Parameters:
Name Type Description
index number
Returns:
Type
string

indexTitle(f)

Get the feature title

Parameters:
Name Type Description
f ol.Feature
Returns:

the first letter of the eature name (getFeatureName)


setIndex(features)

Display features in the index

Parameters:
Name Type Description
features Array.<ol.Feature> | ol.Collection.<ol.Feature>

setMap(map)

Set the map instance the control is associated with.

Parameters:
Name Type Description
map ol.Map

The map instance.

Overrides:

setStyle()

Set Style

Inherited From:
Overrides:

sortFeatures(a, b)

Sort function

Parameters:
Name Type Description
a ol.Feature

first feature

b ol.Feature

second feature

Returns:

0 if a==b, -1 if a<b, 1 if a>b

Type
Number