new GridReference( [Control])
Draw a grid reference on the map and add an index.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
Control |
Object |
<optional> |
options. 1 2 3 4 5 6 7 8 9 10 - style {ol.style.Style} Style to use for drawing the grid (stroke and text), default black.
- maxResolution {number} max resolution to display the graticule
- extent {ol.extent} extent of the grid, required
- size {ol.size} number of lines and cols, required
- margin {number} margin to display text (in px), default 0px
- source {ol.source.Vector} source to use for the index, default none (use setIndex to reset the index)
- 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'.
- sortFeatures {function|undefined} sort function to sort 2 features in the index, default sort on property option
- 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
- filterLabel {string} label to display in the search bar, default 'filter' |
Fires:
- event:select
Extends
Methods
-
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
-
getReference(coords)
-
Get reference for a coord
Parameters:
Name Type Description coords
ol.coordinate Returns:
the reference
- Type
- string
-
getStyle()
-
Get style
Returns:
style
- Type
- ol.style.Style
-
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.
Parameters:
Name Type Description map
ol.Map Map.
-
setStyle(style)
-
Set style
Parameters:
Name Type Description style
ol.style.Style -
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