Class: Workspace

Mapspace. Workspace

The workspace is the core component of Mapspace API. It manages a collection of several Mapspace.Viewer arranged in a Mapspace.Layout.

    var workspace = new Mapspace.Workspace({
        layout: {
            name: 'Dual view',
            views: [
                {
                    column: 0,
                    viewer: new Mapspace.ortho.Viewer({
                        center: [10.219614, 60.157092],
                        zoom: 10
                        layers: [
                            new Mapspace.layer.Tile({
                                name: 'Open Street Map',
                                source: new ol.source.OSM(),
                                visible: false
                            })
                        ]
                     }),
                     controls: [
                         Mapspace.controldef.Zoom(),
                         Mapspace.controldef.North()
                     ]
                },
                {
                     column: 1,
                     viewer: new Mapspace.street.Viewer({
                         center: [10.219614, 60.157092]
                     }),
                     controls: [
                         Mapspace.controldef.Zoom(),
                         Mapspace.controldef.North()
                     ]
                }
          ]
      },
      target: 'workspace'
    });

The above snippet creates a workspace inside a div element with id 'workspace' and initializes it with a dual-view layout in two columns using an Ortho view for the first column and a Street view for the second column, both with a pair of controls attached to their subcontainers.

The constructor places a viewport container (with CSS class name mapspace-workspace) in the target element (see getViewerContainer()), and then several containers inside the viewport, one per each different value of column property (with a CSS class name mapspace-container) and finally several subcontainers inside the previous ones, one per each view with same column value (with a CSS class name mapspace-subcontainer). This simple but powerful method allow the creation of complex layouts.


new Workspace(options)

Parameters:
Name Type Description
options Mapspace.WorkspaceOptions

Workspace options.

Source:
mapspace/workspace.js
Fires:

Extends

  • ol.Object

Members


actions :Array.<Mapspace.action.Action>

Source:
mapspace/workspace.js

apiversion :string

Source:
mapspace/workspace.js

availableProjections :Array.<Mapspace.projectionDefinition>

Source:
mapspace/workspace.js

containers :Array.<Element>

Source:
mapspace/workspace.js

controls :Array.<Mapspace.control.Control>

Source:
mapspace/workspace.js

description :string

Source:
mapspace/workspace.js

language :string

Source:
mapspace/workspace.js

layout :Mapspace.Layout

Source:
mapspace/workspace.js

layoutPresets :Array.<Mapspace.LayoutPreset>|undefined

Source:
mapspace/workspace.js

layoutVisibilities :Array.<boolean>|undefined

Source:
mapspace/workspace.js

name :string

Source:
mapspace/workspace.js

subcontainers :Array.<Element>

Source:
mapspace/workspace.js

viewers :Array.<Mapspace.Viewer>

Source:
mapspace/workspace.js

webversion :string

Source:
mapspace/workspace.js

Methods


addPreset(preset)

Adds a preset to the workspace.

Parameters:
Name Type Description
preset Mapspace.LayoutPreset

The layout preset.

Source:
mapspace/workspace.js

addSyncOption(viewIndex, syncedViewIndex, syncType, status)

Adds the sync option if its not added and set its status. This does not checks the sync option. Use checkSyncOption for that.

Parameters:
Name Type Description
viewIndex number

The index of the viewer with the sync option.

syncedViewIndex number

The index of the synced viewer.

syncType Mapspace.SyncType

Type of syncing.

status boolean

True to activate the sync option, false to deactivate.

Source:
mapspace/workspace.js

changeLayout(column, row, visibility)

Changes the layout modifying the visibility of a viewer. The viewer is identified by its current column row position.

Parameters:
Name Type Description
column number

The column number for the viewer to change.

row number

The row number (rows are inside the previous column) for the viewer to change.

visibility boolean

If should be visible or not.

Source:
mapspace/workspace.js

checkIdleness()

Checks if the current interacted viewer has entered in the idleness state.

Source:
mapspace/workspace.js
Returns:

If current state is idleness or not.

Type
boolean

checkSyncOption(viewIndex, syncedViewIndex, syncType)

Checks if the sync option for the viewer at viewIndex given by the index of the synced viewer and the type of syncing do not cause any problem, usually an infinite loop problem.

For example, if a Mapspace.ortho.Viewer is synced with a Mapspace.threed.Viewer using centerOffset as sync type, and at the same time we want that Threed viewer in sync with the Ortho using centerOffset or center, we can enter in an infinite loop that must be avoided.

Parameters:
Name Type Description
viewIndex number

The index of the viewer with the sync option.

syncedViewIndex number

The index of the synced viewer.

syncType Mapspace.SyncType

Type of syncing.

Source:
mapspace/workspace.js
Returns:

The check status of the sync option. If everything is ok then it returns Mapspace.SyncCheckStatus.OK.

Type
Mapspace.SyncCheckStatus

clearLocalFeatures()

Clear all the local features used by any viewer.

Source:
mapspace/workspace.js

fadeControls(viewer, fadeIn)

Fade controls in or out that are inside a viewer (placed inside its target) and has the fadeOut property set.

Parameters:
Name Type Description
viewer Mapspace.Viewer

Viewer with the controls.

fadeIn boolean

If true controls are faded in, otherwise faded out.

Source:
mapspace/workspace.js

fixSyncOptions()

Fix any problem in the sync options of the layout, making a clean up of bad definitions or removing any sync option that could cause problems.

Source:
mapspace/workspace.js

getActiveViewer()

Gets the viewer that is the active viewer. This viewer implies several effects:

  • Actions for controls like Mapspace.control.FeaturePanel only execute their functionality for the active viewer, although several actions can be linked to the same control.
  • The active viewer is highlighted with a external border controlled by CSS class mapspace-activated.
  • The active viewer is the only one which fades in all internal controls (controls placed inside viewer target), and other viewers have controls faded out according to fadeOut property of them.
Source:
mapspace/workspace.js
Returns:
Type
Mapspace.Viewer

getChanged()

Gets if the workspace is changed from the last time it was saved.

Source:
mapspace/workspace.js
Returns:
Type
boolean

getColumnRow(index)

Returns the column and row for the viewer at the given index.

Parameters:
Name Type Description
index number

Index of the viewer.

Source:
mapspace/workspace.js
Returns:

Array with two numbers, the column and row indexes or undefined if index is out of range.

Type
Array.<number> | undefined

getCurrentLayoutPreset()

Gets the current Mapspace.LayoutPreset that is active or undefined if no one is set or no one is defined.

Source:
mapspace/workspace.js
Returns:
Type
Mapspace.LayoutPreset | undefined

getDefaultActiveViewer()

Gets the viewer that should be set as default active viewer taking account of current visible viewers in the workspace and some rules of precedence. Returns null if no viewer is visible.

Source:
mapspace/workspace.js
Returns:
Type
Mapspace.Viewer

getIndexFromColumnRow(column, row)

Returns the viewer index for the given column and row.

Parameters:
Name Type Description
column number

Index of the column.

row number

Index of the row.

Source:
mapspace/workspace.js
Returns:

Index of the viewer or undefined if index is out of range.

Type
number | undefined

getInteractiveToolForActivation(viewIndex)

Gets the interactive tool that will be selected the next time the given viewer is set as the active viewer or null if no tool must be selected.

The interactive tool that will be selected when a viewer is activated usually is the last one that was selected when the viewer loose the active state.

Parameters:
Name Type Description
viewIndex number

The index of the viewer to get the tool for.

Source:
mapspace/workspace.js
Returns:

The tool name or null.

Type
Mapspace.InteractiveToolNames

getLayout()

Gets the layout.

Source:
mapspace/workspace.js
Returns:

The current layout.

Type
Mapspace.Layout

getNVDBFilterModifiedOptions()

Returns the optional filter to apply to NVDB modified objects in the NVDB panel.

Source:
mapspace/workspace.js
Returns:
Type
Mapspace.nvdb.FilterModifiedOptions

getOutputProjection()

Gets the EPSG code of the selected projection, prefixed with 'EPSG:'. Default is 'EPSG:4326' using the one in Mapspace.DEFAULT_PROJECTIONS.

Source:
mapspace/workspace.js
Returns:
Type
string

getOutputProjectionName()

Gets the name of the selected projection.

Source:
mapspace/workspace.js
Returns:
Type
string

getSize()

Gets the size of this workspace.

Source:
mapspace/workspace.js
Returns:

The size in pixels of the workspace in the DOM.

Type
Mapspace.Size | undefined

getSyncOption(viewIndex, syncedViewIndex, syncType)

Returns the value of the sync option or undefined if no one exists.

Parameters:
Name Type Description
viewIndex number

The index of the viewer with the sync option.

syncedViewIndex number

The index of the synced viewer.

syncType Mapspace.SyncType

Type of syncing.

Source:
mapspace/workspace.js
Returns:
Type
boolean | undefined

getSyncOptionsToSync(viewIndex)

Returns an array of sync options, one per viewer, with only the options to be synced activated. Calculates the direct syncs and indirect syncs and mix all them together. If a previous array of sync options was cached, then it is the returned one.

Parameters:
Name Type Description
viewIndex number

The index of the interacted viewer.

Source:
mapspace/workspace.js
Returns:
Type
Array.<Mapspace.SyncProperties>

getTarget()

Gets the target in which the workspace is rendered. Note that this returns what is entered as an option or in setTarget: if that was an element, it returns an element; if a string, it returns that.

Source:
mapspace/workspace.js
Returns:

The Element or id of the Element that the workspace is rendered in.

Type
Element | string | undefined

getTargetElement()

Gets the DOM element into which this workspace is rendered. In contrast to getTarget this method always return an Element, or null if the workspace has no target.

Source:
mapspace/workspace.js
Returns:

The element that the workspace is rendered in.

Type
Element

getUnits()

Gets the units for the workspace. These units will be used when a coordinates or measurements are reported in any control related to viewers.

Source:
mapspace/workspace.js
Returns:
Type
ol.proj.Units

getViewerName(index)

Returns the name of a viewer. If names are not provided when defined the workspace then an automatic name is provided.

Parameters:
Name Type Description
index number

Index of the viewer.

Source:
mapspace/workspace.js
Returns:

The name or undefined if index is out of range.

Type
string | undefined

getWorkLists()

Returns the reference to the array of work lists. Use this reference to change any value inside it.

Source:
mapspace/workspace.js
Returns:
Type
Array.<Mapspace.WorkList>

isViewerVisible(column, row)

Returns true if the viewer at the given column and row in current layout of the workspace is visible. Otherwise false.

Parameters:
Name Type Description
column number

The column number for the viewer to check. If the column is outside bounds then return false.

row number

The row number (rows are inside the previous column) for the viewer to check. If the row is outside bounds then return false.

Source:
mapspace/workspace.js
Returns:
Type
boolean

removeControls(type, viewer, className)

Removes a current control of the viewer

Parameters:
Name Type Description
type object

The type of the control.

viewer object

Viewer

className string

The class name of the control.

Source:
mapspace/workspace.js

removePreset(name)

Removes a preset with the given name if exists.

Parameters:
Name Type Description
name string

The name of the preset to remove.

Source:
mapspace/workspace.js

removeSyncOption(viewIndex, syncedViewIndex, syncType)

Removes the sync option.

Parameters:
Name Type Description
viewIndex number

The index of the viewer with the sync option.

syncedViewIndex number

The index of the synced viewer.

syncType Mapspace.SyncType

Type of syncing.

Source:
mapspace/workspace.js

save(newName)

Returns a Promise that executes a save operation of this workspace in the server. Optionally a new name can be provided to the workspace during save operation. If save is a success the promise make this workspace trigger a SAVED or RENAMED event when server responses and then call the resolve function. The resolve function receives a boolean TRUE value, and the reject function an Error.

Parameters:
Name Type Argument Description
newName string <nullable>

Optional new name for the workspace.

Source:
mapspace/workspace.js
Returns:
Type
Promise

setActiveViewer(viewer)

Sets a viewer as the active viewer. This viewer implies several effects:

  • Actions for controls like Mapspace.control.FeaturePanel only execute their functionality for the active viewer, although several actions can be linked to the same control.
  • The active viewer is highlighted with a external border controlled by CSS class mapspace-activated if there are two or more visible viewers.
  • The active viewer is the only one which fades in all internal controls (controls placed inside viewer target), and other viewers have controls faded out according to fadeOut property of them.
Parameters:
Name Type Description
viewer Mapspace.Viewer

The viewer to set as active viewer.

Source:
mapspace/workspace.js

setChanged(changed)

Sets if the workspace is changed or not.

Parameters:
Name Type Description
changed boolean

If the workspace has changed or not.

Source:
mapspace/workspace.js

setInteractiveToolForActivation(viewIndex, tool [, opt_control])

Sets the interactive tool that will be selected the next time the given viewer is set as the active viewer.

The interactive tool that will be selected when a viewer is activated usually is the last one that was selected when the viewer loose the active state. With this function it is possible to change what tool the viewer will use on activation.

Parameters:
Name Type Argument Description
viewIndex number

The index of the viewer to set the tool for.

tool Mapspace.InteractiveToolNames

The tool to use on activation.

opt_control Mapspace.control.Control <optional>

An optional control that contains the tool to use on activation. This param is important when several controls contains the exactly same interactive tool.

Source:
mapspace/workspace.js

setNVDBFilterModifiedOptions(filter)

Sets the optional filter to apply to NVDB modified objects in the NVDB panel.

Parameters:
Name Type Argument Description
filter Mapspace.nvdb.FilterModifiedOptions <nullable>

The filter.

Source:
mapspace/workspace.js

setOutputProjection(epsgcode)

Sets the EPSG code of the selected projection, prefixed with 'EPSG:'. Default is 'EPSG:4326' using the one in Mapspace.DEFAULT_PROJECTIONS.

Parameters:
Name Type Description
epsgcode string

EPSG code, prefixed with 'EPSG:'.

Source:
mapspace/workspace.js

setResizeListening(listen)

Adds or remove resize events listening for the workspace and viewers.

Parameters:
Name Type Description
listen boolean

If true listening of resize events is activated; if false deactivated.

Source:
mapspace/workspace.js

setSize(size)

Sets the size of this workspace.

Parameters:
Name Type Description
size Mapspace.Size | undefined

The size in pixels of the workspace in the DOM.

Source:
mapspace/workspace.js

setTarget(target)

Sets the target element to render this workspace into.

Parameters:
Name Type Description
target Element | string | undefined

The Element or id of the Element that the workspace is rendered in.

Source:
mapspace/workspace.js

setUnits(units)

Sets the units for the workspace. These units will be used when a coordinates or measurements are reported in any control related to viewers.

Parameters:
Name Type Description
units ol.proj.Units

Units.

Source:
mapspace/workspace.js

setVisibilityOfSyncedViewers(viewer, syncType, visible)

Change visibility to true for all viewers that are synced for given viewer and sync type.

Parameters:
Name Type Description
viewer Mapspace.Viewer

Viewer to check which viewers are synced.

syncType Mapspace.SyncType

Type of synchronization that must be active.

visible boolean

If visibility is true or not.

Source:
mapspace/workspace.js

syncViewer(viewIndex)

Updates a visible viewer to reflect the sync options that affect it. This loops through all the existing sync options in the workspace and apply those that affect the given viewer. If several viewers affect the same property then the first viewer in the list of viewers is used.

Parameters:
Name Type Description
viewIndex number

The index of the viewer to update.

Source:
mapspace/workspace.js

updateSize()

Force a recalculation of the workspace viewport size. This should be called when third-party code changes the size of the workspace viewport.

Source:
mapspace/workspace.js

updateSyncedOverlays()

Updates all overlays in viewers that have that synced overlays. Currently only 2D viewers (Ortho, Oblique & Global) are capable of show overlays. Iterates through all the viewers, check if there is any viewers with appropiate syncing properties, and sync the required viewers.

Source:
mapspace/workspace.js