Methods
# addHeatmapLayer(map, layer) → {HeatmapLayer}
Takes a vector layer and returns a heatmap layer
Parameters:
Name | Type | Description |
---|---|---|
map |
Object | Openlayers map object |
layer |
Layer | A vector layer that will be used to create heatmap layer |
- Since:
- 1.13.0
View Source LayerPanel/LayerPanelActionHeatmap/utils.js, line 15
HeatmapLayer
HeatmapLayer
# addMovementListener(map, callback) → {Array.<ol.EventsKey>}
Bind multiple move listeners with the same callback
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map | The openlayers map to which the events are bound |
callback |
function | The callback invoked when a `change:size`, `change:resolution` or a `change:center` event was fired |
- Since:
- 0.2.0
Array of openlayers event keys for unsetting listener events (use with removeMovementListener)
Array.<ol.EventsKey>
# addSelectInteraction(map, name, opts) → {Object}
Create a new openlayers select interaction with default styling and add the vector layer to the map
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map | reference to the openlayers map object |
name |
String | identifier to set as _ol_kit_origin on the interaction |
opts |
Object | select interaction opts |
- Since:
- 1.11.0
object - { layer: {ol.layer.Vector} https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html, select: {ol.interaction.Select} https://openlayers.org/en/latest/apidoc/module-ol_interaction_Select-Select.html }
Object
# addVectorLayer(map, featuresopt) → {Layer}
Takes an array of vector features and creates a new layer
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
map |
Object | Openlayers map object | |
features |
Array.<Object> |
<optional> |
An array of the features to be included in the new layer |
- Since:
- 1.13.0
View Source LayerPanel/LayerPanelActionMerge/utils.js, line 17
VectorLayer
Layer
# calculateViewPadding(map, opts) → {Array}
Calculate bounding box of elements on page with _popup_boundary class and returns padding array excluding area of these elements
Parameters:
Name | Type | Description |
---|---|---|
map |
olMap | An instance of an openlayers map |
opts |
Object |
- Array of view padding pixel numbers: [top, right, bottom, left]
Array
# centerAndZoom(map, opts) → {Array}
Update the map location to provided zoom & x, y coordinates
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map | reference to the openlayers map object |
opts |
Object | include x, y, & zoom options |
- Since:
- 0.1.0
Coordinates used to update the map
Array
# connectToContext(component) → {Component}
A wrapper utility function designed to automatically pass down provider conntext as props from the Provider component
Parameters:
Name | Type | Description |
---|---|---|
component |
Component | A React component you want wrapped |
- Since:
- 1.0.0
A wrapped React component which will automatically be passed a reference to provider context
Component
# convertFeatureToWkt(feature, decimalPlacesopt) → {String}
Convert a feature to a WKT string
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
feature |
Object | An ol/Feature | |
decimalPlaces |
Number |
<optional> |
the number of decimal places in the output coordinates |
The WKT string of the feature passed
String
# convertFileToFeatures(fileopt, mapopt)
Converts the given file into an array of features
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
file |
Blob |
<optional> |
the file to be converted. Accepts, 'kmz', 'kml', 'geojson', 'wkt', 'csv', 'zip', and 'json' file types. |
map |
olMap |
<optional> |
the openlayers map |
- Since:
- 7.0.0
View Source LayerPanel/LayerPanelActionImport/utils.js, line 47
# convertFileToLayer(fileopt, mapopt)
Converts the given file into a layer
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
file |
Blob |
<optional> |
the file to be converted. Accepts, 'kmz', 'kml', 'geojson', 'wkt', 'csv', 'zip', and 'json' file types. |
map |
olMap |
<optional> |
the openlayers map |
# convertSvgToPDFTemplate(svg, inputs, opts) → {Object}
Take an svg template and list of inputs and convert it into a fully loaded template to print a PDF
Parameters:
Name | Type | Description |
---|---|---|
svg |
String | Stringified svg used as a template for creating pdf |
inputs |
Array.<Object> | Array of inputs that fill in the svg elements required: { id: string, type: 'text' | 'image', content: canvas | string, uri: string } |
opts |
Object | Non template options: { fileName: string } |
- Since:
- 1.12.0
Template ready to be used by `printPDF`
Object
# convertXYtoLatLong(map, x, y) → {Object}
Convert an XY pair to lat/long
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map | reference to the openlayers map object |
x |
Number | the x coordinate |
y |
Number | the x coordinate |
- Since:
- 0.16.0
An object containing a `longitude` and `latitude` property
Object
# copyTextToClipboard(text)
Copy text to the clipboard
Parameters:
Name | Type | Description |
---|---|---|
text |
String | The string to copy to the system clipboard |
# copyWktToClipbard(feature, decimalPlacesopt)
Given an ol/Feature, copy its WKT string to the system clipboard
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
feature |
Object | An ol/Feature | |
decimalPlaces |
Number |
<optional> |
the number of decimal places in the output coordinates |
# createMap(optsopt) → {ol.Map}
Create an openlayers map
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opts |
Object |
<optional> |
Object of optional params |
isSyncableMap |
String |
<optional> |
flag to return a SyncableMap class for multi-map implementations |
target |
String |
<optional> |
html id tag that map will into which the map will render |
- Since:
- 0.1.0
A newly constructed ol.Map
ol.Map
# createProject(map) → {object}
A utility that takes map state and outputs it as a project file
Parameters:
Name | Type | Description |
---|---|---|
map |
Map | a reference to openlayers map |
- Since:
- 1.9.0
- object in ol-kit project format
object
# createSelectInteraction(opts) → {ol.interaction.Select}
Create a new openlayers select interaction with default styling
Parameters:
Name | Type | Description |
---|---|---|
opts |
Object | select interaction opts |
- Since:
- 0.2.0
https://openlayers.org/en/latest/apidoc/module-ol_interaction_Select-Select.html
ol.interaction.Select
# exportFeatures(typeopt, featuresopt)
Exports the passed features as a file of the desired type.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
String |
<optional> |
The desired file type ('shp' or 'kml'). |
features |
Array.<Object> |
<optional> |
An array of the features to be included in the generated file. |
- Since:
- 0.9.0
View Source LayerPanel/LayerPanelActionExport/utils.js, line 34
# getExtentForFeatures(featureList) → {ol.Extent}
Calculates a map extent that would make all features in the list visible.
Parameters:
Name | Type | Description |
---|---|---|
featureList |
Array.<ol.Feature> | List of Open Layers features |
Map extent
ol.Extent
# getLayersAndFeaturesForEvent(event, optsopt) → {Array.<Promise>}
Get all features for a given click event
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
Object | An object with a `map` and `pixel` property | ||
map |
ol.Map | The openlayers map where the layer exists | ||
pixel |
Array.<Number> | An array consisting of `x` and `y` pixel locations | ||
opts |
Object |
<optional> |
Object of optional params | |
hitTolerance |
Number |
<optional> |
3 | Additional area around features that is clickable to select them |
- Since:
- 0.2.0
An array of promises, each of which resolve to an object `{ layer, features }`
Array.<Promise>
# getPixelValue(layer, event) → {ol.Feature}
Creates a new feature with point geometry at the location of the pixel and attributes describing the pixel's value
Parameters:
Name | Type | Description |
---|---|---|
layer |
ol.Layer | The openlayers layer |
event |
Object | An object with a `map` and `pixel` property |
- Since:
- 1.17.0
An openlayers feature with point geometry at the location of the pixel and attributes describing the pixel's value
ol.Feature
# getPopupPositionFromFeatures(event, features, optsopt) → {Object}
Get the best position for the popup to be displayed given features
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
event |
Object | An object with an `event` and `pixel` property | ||
map |
ol.Map | The openlayers map where the layer exists | ||
pixel |
Array.<Number> | An array consisting of `x` and `y` pixel locations | ||
features |
Array.<ol.Feature> | An array of features around which the popup should position | ||
opts |
Object |
<optional> |
||
popupHeight |
Number |
<optional> |
280 | The height of the popup |
popupWidth |
Number |
<optional> |
280 | The width of the popup |
arrowHeight |
Number |
<optional> |
16 | The height of the popup's arrow/pointer |
navbarOffset |
Number |
<optional> |
55 | The height of the navbar |
viewPadding |
Array.<Number> |
<optional> |
[0, 0, 0, 0] | An array of padding to apply to the best fit logic in top, right, bottom, left order |
An object containing the arrow/pointer position, pixel location & if the popup will fit properly within the viewport
Object
# getSelectInteraction(map, name) → {Object}
Find a select interaction on the map by name (defaults to internal select created by ol-kit if name not passed)
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map | reference to the openlayers map object |
name |
String | identifier to find _ol_kit_origin on the select interaction |
- Since:
- 1.11.0
object - { layer: {ol.layer.Vector} https://openlayers.org/en/latest/apidoc/module-ol_layer_Vector-VectorLayer.html, select: {ol.interaction.Select} https://openlayers.org/en/latest/apidoc/module-ol_interaction_Select-Select.html }
Object
# getStyledFeatures(layers, resolutionopt)
Generate a 2D array of features paired to a style representing how they are currently styled on the map.
OpenLayers Features will inherit the style set on their parent layer if their own style is undefined. This Function helps resolve the style that is actually being used to render the feature on the map.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
layers |
Array.<Object> | The Openlayers Layers you want to get the features from. | |
resolution |
Number |
<optional> |
The map's current resolution. |
# immediateEditStyle(opts, feature, resolution) → {object}
Style an ol/Feature with orange circle vertices, a blue outline, an area label, and a perimeter length label. Can be used with individual features as a style function or call it directly to get a style object for use with `vectorContext.drawFeature`
Parameters:
Name | Type | Description |
---|---|---|
opts |
object | The config object |
feature |
ol/Feature | The feature you want to style |
resolution |
number | the resolution of the map |
The style object for the passed feature
object
# loadBasemapLayer(map, basemapIdentifier)
A utility that takes a string identifier and updates the basemap
Parameters:
Name | Type | Description |
---|---|---|
map |
Map | a reference to openlayers map |
basemapIdentifier |
basemapIdentifier | string identifier to update the basemap |
- Since:
- 1.9.0
# loadDataLayer(map, query, optsopt) → {ol.Layer}
Async fetch for data layers - supports geojson, kml
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
map |
ol.Map | reference to the openlayer map object | |
query |
String | url string pointing to geojson/kml file or the geojson/kml file itself | |
opts |
Object |
<optional> |
Object of optional params |
addToMap |
Boolean |
<optional> |
opt out of adding the layer to the map (default true) |
style |
String |
<optional> |
style object used to apply styles to the layer |
title |
String |
<optional> |
set custom title on layer (default: "Data Layer") |
- Since:
- 0.8.0
Promise that resolves with the newly created data layer
ol.Layer
# loadProject(map) → {object}
A utility that accepts an ol-kit project file and updates the map state
Parameters:
Name | Type | Description |
---|---|---|
map |
Map | a reference to openlayers map |
- Since:
- 1.9.0
- object in ol-kit project format
object
# mergeLayerFeatures(VectorLayer) → {Feature}
Takes an array of vector features and creates a new merged geometry
Parameters:
Name | Type | Description |
---|---|---|
VectorLayer |
Layer | VectorLayer with features to be merged |
- Since:
- 1.17.0
View Source LayerPanel/LayerPanelActionMergeFeatures/utils.js, line 97
olFeature
Feature
# printPDFTemplate(template, opts) → {Object}
Build a PDF from a template and print locally
Parameters:
Name | Type | Description |
---|---|---|
template |
Object | { elements, dimensions, orientation, unit, fileName } |
opts |
Object | PDF options: { hideLogo: false } |
- Since:
- 1.12.0
Object
# removeMovementListener(map, keys)
Remove list of event keys
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map | The openlayers map to which the events are bound |
keys |
Array | remove the listeners via` an array of event keys |
- Since:
- 0.2.0
# sanitizeProperties(properties) → {Object}
Remove blacklisted attributes (geom & geometry & _ol_kit*) from an object
Parameters:
Name | Type | Description |
---|---|---|
properties |
Object | A feature attribute object |
- Since:
- 0.11.0
A filtered attribute object
Object
# setMapExtent(map, extent)
Sets the map extent to the given values.
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map | Open Layers map |
extent |
ol.Extent | New extent definition |
# styleText(opts, feature, resolution, opts) → {object}
Style ol/features
Parameters:
Name | Type | Description |
---|---|---|
opts |
object | The config object |
feature |
ol/Feature | The feature you want to style |
resolution |
number | the resolution of the map |
opts |
object | The config object |
The style object for the passed feature
object
# styleText(opts, feature, resolution) → {object}
Style ol/Features
Parameters:
Name | Type | Description |
---|---|---|
opts |
object | The config object |
feature |
ol/Feature | The feature you want to style |
resolution |
number | the resolution of the map |
The style object for the passed feature
object
# syncViewEvents(viewsopt)
Sync multiple openlayers
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
views |
Object |
<optional> |
Array of openlayers views |
- Since:
- 1.7.0
# updateMapFromUrl(map, viewParam) → {Promise}
Update the map view with location coordinates, zoom level & rotation from the url
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map | reference to the openlayers map object |
viewParam |
String | the query param that will be read to update the map position |
- Since:
- 0.1.0
Resolved with transformed center coords after the map has been updated by url info
Promise
# updateUrlFromMap(map, viewParam) → {String}
Update the url with map location coordinates, zoom level & rotation
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map | reference to the openlayers map object |
viewParam |
String | the query param that will be used to update the url with view info |
- Since:
- 0.1.0
The url that is set within the function
String
# VectorLayer(optsopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opts |
Object |
<optional> |
Object of optional params for olLayerVector |
- Since:
- 0.1.0
# VectorTileLayer(optsopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
opts |
Object |
<optional> |
Object of optional params for olLayerVector |
- Since:
- 1.4.0