Home Reference Source
public class | source

Openlayers

Extends:

Queueable → Openlayers

Example:

//

Member Summary

Public Members
public
public

maps: {}

public

overlays: {}

public

queue: *

public

Method Summary

Public Methods
public

addFeature(pid: *, json: *)

Add a feature to the Map TODO: This is old code for getting something working.

public

addGeojson(pid: *, json: *)

Add geojson features to a layer

public

addLayer(pid: int, json: object): boolean

Add a layer to the map

public

addMap(pid: int, json: object)

Create a new map

public

addOverlay(pid: *, json: *)

Add an overlay to the map

public

addRenderComplete(pid: int, json: object)

Add an event that sets a register when render is complete

public

animateZoom(pid: *, json: *)

Zoom a layer to the extent of its features (needs appropriate zoom levels to work well

public

centerOnCoordinate(pid: *, json: *)

Move the map so the cords are at the center

public

changed(pid: *, json: *)

Flag a layer as changed (cause redraw).

public

clearLayer(pid: *, json: *)

Remove the data from a layer on the map.

public

controlSet(pid: *, json: *)

Set a controls(s) to the requested mode and set others to opposit state

public

controlTrigger(pid: *, json: *)

trigger a controls(s) sub functions (init is default) See example in simple select for how to code for this

public

coordinatesToWKT(pid: *, json: *)

Convert a coordinate to WKT

public

deleteFeatureById(pid: *, json: *)

Delete features from layer by id

public

enableAllMapsLoadedCheck(pid: *, json: *)

public

enableLoadCheck(pid: *, json: *)

public

findFeatures(pid: *, json: *): *

Use a filter object to locate features on a single layer

public

flyTo(pid: *, json: *)

Zoom a layer to the extent of its features (needs appropriate zoom levels to work well

public

getGeojson(pid: *, json: *)

gets geojson features to a layer

public

init(queue: *)

public

makeContiguous(pid: *, json: *)

public

makeControl(pid: *, json: *): boolean

Make a new control

public

mergeFeaturesById(pid: *, json: *)

merge features from layer by id

public

propertiesClean(pid: *, json: *)

Clean and/or default feature properties

public

removeOverlay(pid: *, json: *)

Remove an overlay from the map

public

setFeaturePropertyById(pid: *, json: *)

Set a features properties by id

public

setFeaturesPropertiesById(pid: *, json: *)

Set features properties by id

public

setLayerActive(pid: *, json: *)

set layer on or off

public

simpleClick(pid: *, json: *)

Use the standard click event

public

splitFeatures(pid: *, json: *): boolean

split featues using a line string

public

toggleLayer(pid: *, json: *)

Toggle layer on and off

public

updateResolution(pid: *, json: *)

public

updateSize(pid: *, json: *)

Update size of map (in the event of resize or rotation this will fix it)

public

zoomToLayerExtent(pid: *, json: *)

Zoom a layer to the extent of its features (needs appropriate zoom levels to work well

Private Methods
private

_addLayer_heatmap(options: *): VectorLayer

Add a heatmap layer

private

_addLayer_osm(options: *): TileLayer

Add an osm layer

private

_addLayer_vector(options: *): VectorLayer

Add a vector layer

private

_addLayer_wms(options: *): TileLayer

Add a wms layer

private

_addLayer_wmts(options: *): TileLayer

Add an wmts layer

private

_addLayer_xyz(options: *): TileLayer

Add an xyz layer

private

_checkLayerLoadState(map: *, register: *): boolean

private
private

_cleanCoords(coords: *): *

private

_control_drawFeature(json: *): *

private

_control_multiEdit(json: *): *

MultiEdit tool

private

_control_simpleSelect(json: *): *

Use the standard openlayers select control

private

_control_snap(json: *): *

private

_debug(event: *)

private

_decodeCoords(cords: *, projection: *): number[]

Clean up coordinates in any format and reproject

private

_featureSearch(source: *, searchString: *): *

private

_featureToTurfPolygon(feature: *): []

Convert a feature of polygons to a turf polygon of correct type

private

_featuresToGeojson(toProjection: *, fromProjection: *, features: *): *

turn a features array into gejson

private

_idFeatures(features: *): *

Openlayers doesn't ID features by default. This will apply a unique id to all features passed to it

private

_loadGeojson(geojson: *): *

Loads geojson from var or object

private

_makeContiguous(featuresJSON: *, tolerance: *)

private

_multiFeatureToPolygon(feature: *): []

Convert a feature of multiPolygon to a featue(s) of Polygons.

private

_toggleControl(map: *, control: *)

Toggle a control between on/off

private

_updateResolution(map: *, name: *)

Inherited Summary

From class Queueable
public

queue: *

public
public

finished(pid: *, mode: *)

Call this method after you command has finished.

public

init(queue: *)

init, override this for any promise based inits setting the self.ready=true after the promise

public

set(pid: *, value: *)

public

start(pid: *, command: *, json: *)

Called from queue, starts running the actual command

Public Members

public allMapsLoadedCheck: boolean source

public maps: {} source

public overlays: {} source

public queue: * source

Override:

Queueable#queue

public ready: boolean source

Override:

Queueable#ready

Public Methods

public addFeature(pid: *, json: *) source

Add a feature to the Map TODO: This is old code for getting something working. Needs functionising, not for production

Params:

NameTypeAttributeDescription
pid *
json *

public addGeojson(pid: *, json: *) source

Add geojson features to a layer

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to get extent from

json.gejson string

geojson

public addLayer(pid: int, json: object): boolean source

Add a layer to the map

Params:

NameTypeAttributeDescription
pid int

process ID

json object

queue arguments

json.map string

name for the map (used to reference)

json.name string

name for the layer (used to reference)

json.typr string

Layer type osm,vector

json.opacity float

layer opacity

json.transparent boolean

is the layer transparent?

json.style string

Style object to use

json.active boolean

Is the layer active

json.loadIgnore boolean

Ignore this layer for loadchecking

json.geojson object | string

geojson to add to the layer (vector)

Return:

boolean

Example:

openlayer.addLayer();

public addMap(pid: int, json: object) source

Create a new map

Params:

NameTypeAttributeDescription
pid int

process ID

json object

queue arguments

json.map string

name for the map (used to reference)

json.target string

id of element in the page to target

json.zoom int

initial zoom level

json.maxZoom int

Maximum zoom

json.center array

Center on

json.renderer string

Renderers to use

Example:

openlayer.addMap();

public addOverlay(pid: *, json: *) source

Add an overlay to the map

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.overlay string

Overlay reference to use

json.targetId string

Dom element to use

json.coordinate string

coordinate to place it (Event.coordinate) for clicks

Example:

openlayers.addOverlay({"targetId":"#functionOverlay","coordinate":"{{!^JSON.stringify(memory.simpleSelect.value.mapBrowserEvent.coordinate)}}"});

public addRenderComplete(pid: int, json: object) source

Add an event that sets a register when render is complete

Be warned this only works if you start it after all layers are added and those layer include their data

Params:

NameTypeAttributeDescription
pid int

process ID

json object

queue arguments

json.map string

name for the map (used to reference)

Example:

openlayer.addRenderComplete();

public animateZoom(pid: *, json: *) source

Zoom a layer to the extent of its features (needs appropriate zoom levels to work well

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.inc string

Increment of he zoom EG 1|-1|2|-2|etc

json.delay string

Delay period of the zoom in ms

Example:

openlayers.animateZoom({"inc":"2});

public centerOnCoordinate(pid: *, json: *) source

Move the map so the cords are at the center

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.coordinate string

Coordinate to use

Example:

openlayers.centerOnCoordinate({"coordinate":"{{!^JSON.stringify(memory.simpleSelect.value.selected[0].getGeometry().getCoordinates())}}"});

public changed(pid: *, json: *) source

Flag a layer as changed (cause redraw).

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to flag

public clearLayer(pid: *, json: *) source

Remove the data from a layer on the map.

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to clear

public controlSet(pid: *, json: *) source

Set a controls(s) to the requested mode and set others to opposit state

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map name

json.mode string

on|off

json.name array

control to set

public controlTrigger(pid: *, json: *) source

trigger a controls(s) sub functions (init is default) See example in simple select for how to code for this

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map name

json.function string

function to call

json.name array

control to call

public coordinatesToWKT(pid: *, json: *) source

Convert a coordinate to WKT

Params:

NameTypeAttributeDescription
pid *
json *

public deleteFeatureById(pid: *, json: *) source

Delete features from layer by id

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to get extent from

json.id string

id of feature

public enableAllMapsLoadedCheck(pid: *, json: *) source

Params:

NameTypeAttributeDescription
pid *
json *

public enableLoadCheck(pid: *, json: *) source

Params:

NameTypeAttributeDescription
pid *
json *

public findFeatures(pid: *, json: *): * source

Use a filter object to locate features on a single layer

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map name

json.layer array

layer to use

json.filter object

Filter eg {"feature_id":1}

Return:

*

public flyTo(pid: *, json: *) source

Zoom a layer to the extent of its features (needs appropriate zoom levels to work well

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.duration string

Delay period of the zoom in ms

json.coordinate string

location to fly to

json.wait boolean

Wait till end of animation to finish queue item

Example:

openlayers.flyTo({"location":"2});

public getGeojson(pid: *, json: *) source

gets geojson features to a layer

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to get extent from

json.prefix string

Prefix for memory

json.projection string

Projection to use

json.search string

feature search to use (rather than all)

public init(queue: *) source

init, override this for any promise based inits setting the self.ready=true after the promise

Override:

Queueable#init

Params:

NameTypeAttributeDescription
queue *

public makeContiguous(pid: *, json: *) source

Params:

NameTypeAttributeDescription
pid *
json *

public makeControl(pid: *, json: *): boolean source

Make a new control

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map name

json.mode string

on|off

json.name array

What to call it (used later to reference)

json.control array

The control function to use

Return:

boolean

public mergeFeaturesById(pid: *, json: *) source

merge features from layer by id

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to get extent from

json.ids string

ids of features to merge

public propertiesClean(pid: *, json: *) source

Clean and/or default feature properties

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to get features from

json.delete array

Array of properties to delete

json.default array

Array of objects {name:...,value:...} to default

public removeOverlay(pid: *, json: *) source

Remove an overlay from the map

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.overlay string

Overlay reference to use

Example:

openlayers.removeOverlay();

public setFeaturePropertyById(pid: *, json: *) source

Set a features properties by id

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map name

json.layer array

layer to use

json.id object

Feature id

json.properties object

properties to set

public setFeaturesPropertiesById(pid: *, json: *) source

Set features properties by id

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map name

json.layer array

layer to use

json.id array

Feature id array

json.properties object

properties to set

public setLayerActive(pid: *, json: *) source

set layer on or off

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to clear

json.active string

active state to set

public simpleClick(pid: *, json: *) source

Use the standard click event

Params:

NameTypeAttributeDescription
pid *
json *

public splitFeatures(pid: *, json: *): boolean source

split featues using a line string

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to get extent from

json.id string

id of feature

Return:

boolean

public toggleLayer(pid: *, json: *) source

Toggle layer on and off

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to clear

public updateResolution(pid: *, json: *) source

Params:

NameTypeAttributeDescription
pid *
json *

public updateSize(pid: *, json: *) source

Update size of map (in the event of resize or rotation this will fix it)

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference can be * and all maps will be targeted

Example:

openlayers.updateSize({"map":"map_1"});

public zoomToLayerExtent(pid: *, json: *) source

Zoom a layer to the extent of its features (needs appropriate zoom levels to work well

Params:

NameTypeAttributeDescription
pid *
json *
json.map string

Map reference

json.layer string

Layer to get extent from

Example:

openlayers.zoomToLayerExtent({"map":"map_1","layer":"data"});

Private Methods

private _addLayer_heatmap(options: *): VectorLayer source

Add a heatmap layer

Params:

NameTypeAttributeDescription
options *

Return:

VectorLayer

private _addLayer_osm(options: *): TileLayer source

Add an osm layer

Params:

NameTypeAttributeDescription
options *

Return:

TileLayer

private _addLayer_vector(options: *): VectorLayer source

Add a vector layer

Params:

NameTypeAttributeDescription
options *

Return:

VectorLayer

private _addLayer_wms(options: *): TileLayer source

Add a wms layer

Params:

NameTypeAttributeDescription
options *

Return:

TileLayer

private _addLayer_wmts(options: *): TileLayer source

Add an wmts layer

Params:

NameTypeAttributeDescription
options *

Return:

TileLayer

private _addLayer_xyz(options: *): TileLayer source

Add an xyz layer

Params:

NameTypeAttributeDescription
options *

Return:

TileLayer

private _checkLayerLoadState(map: *, register: *): boolean source

Params:

NameTypeAttributeDescription
map *
register *

Return:

boolean

private _checkMapLoadState(): boolean source

Return:

boolean

private _cleanCoords(coords: *): * source

Params:

NameTypeAttributeDescription
coords *

Return:

*

private _control_drawFeature(json: *): * source

Params:

NameTypeAttributeDescription
json *

Return:

*

private _control_multiEdit(json: *): * source

MultiEdit tool

Params:

NameTypeAttributeDescription
json *
json.map string

Map name

json.layer array

layer to use

json.mode object

on|off

json.projection object

properties to set

json.inside object

JSON with single feature to use

json.buffer object

buffer in meters around the inside

Return:

*

private _control_simpleSelect(json: *): * source

Use the standard openlayers select control

Params:

NameTypeAttributeDescription
json *
json.map string

Map name

json.mode string

on|off

json.perfix string

prefix to use

json.layers array

layers to use

Return:

*

private _control_snap(json: *): * source

Params:

NameTypeAttributeDescription
json *

Return:

*

private _debug(event: *) source

Params:

NameTypeAttributeDescription
event *

private _decodeCoords(cords: *, projection: *): number[] source

Clean up coordinates in any format and reproject

Params:

NameTypeAttributeDescription
cords *
projection *

Return:

number[]

private _featureSearch(source: *, searchString: *): * source

Params:

NameTypeAttributeDescription
source *
searchString *

Return:

*

private _featureToTurfPolygon(feature: *): [] source

Convert a feature of polygons to a turf polygon of correct type

Params:

NameTypeAttributeDescription
feature *

Return:

[]

private _featuresToGeojson(toProjection: *, fromProjection: *, features: *): * source

turn a features array into gejson

Params:

NameTypeAttributeDescription
toProjection *
fromProjection *
features *

Return:

*

private _idFeatures(features: *): * source

Openlayers doesn't ID features by default. This will apply a unique id to all features passed to it

Params:

NameTypeAttributeDescription
features *

Return:

*

private _loadGeojson(geojson: *): * source

Loads geojson from var or object

Params:

NameTypeAttributeDescription
geojson *

Return:

*

private _makeContiguous(featuresJSON: *, tolerance: *) source

Params:

NameTypeAttributeDescription
featuresJSON *
tolerance *

private _multiFeatureToPolygon(feature: *): [] source

Convert a feature of multiPolygon to a featue(s) of Polygons. No properies are copied

Params:

NameTypeAttributeDescription
feature *

Return:

[]

private _toggleControl(map: *, control: *) source

Toggle a control between on/off

Params:

NameTypeAttributeDescription
map *
control *

private _updateResolution(map: *, name: *) source

Params:

NameTypeAttributeDescription
map *
name *