Methods
# 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>
# 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 openlayer 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 |
- Since:
- 6.5.0
View Source LayerPanel/LayerPanelActionImport/utils.js, line 26
# convertXYtoLatLong(map, x, y) → {Object}
Convert an XY pair to lat/long
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map | reference to the openlayer 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 |
target |
String |
<optional> |
htm id tag that map will into which the map will render |
- Since:
- 0.1.0
A newly constructed ol.Map
ol.Map
# createSelectInteraction() → {ol.interaction.Select}
Create a new openlayers select interaction with default styling
- 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
# getLayersAndFeaturesForEvent(event, optsopt) → {Array.<Promise>}
Get all features for a given click event
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 | ||
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>
# 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
# 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. |
# 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 |
- Since:
- 0.8.0
Promise that resolves with the newly created data layer
ol.Layer
# 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
# 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
# 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 openlayer 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 openlayer 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