Class: GridReference

ol.control. GridReference


new GridReference( [Control])

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

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:

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:

getReference(coords)

Get reference for a coord

Parameters:
Name Type Description
coords ol.coordinate
Returns:

the reference

Type
string

getStroke()

Get stroke

Inherited From:

getStyle()

Get style

Inherited From:

getTextFill()

Get text fill

Inherited From:

getTextFont()

Get text font

Inherited From:

getTextStroke()

Get stroke

Inherited From:

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)

Remove the control from its current map and attach it to the new map. Subclasses may set up event handlers to get notified about changes to the map here.

Parameters:
Name Type Description
map o.Map

Map.

Inherited From:

setStyle()

Set Style

Inherited From:

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