Class: Workspace

bu. Workspace

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

var workspace = new bu.Workspace({
    layout: {
        name: 'Dual view',
        views: [
            {
                column: 0,
                viewer: new bu.ortho.Viewer({
                    center: [0, 0],
                    zoom: 1
                    layers: [
                        "OSM"
                    ]
                 }),
                 controls: [
                     bu.ortho.controldef.Zoom(),
                     bu.ortho.controldef.North()
                 ]
            },
            {
                 column: 1,
                 viewer: new bu.street.Viewer({
                     center: ol.proj.fromLonLat([10.219614, 60.157092])
                 }),
                 controls: [
                     bu.street.controldef.Zoom(),
                     bu.street.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 pairs of controls attached to their subcontainers.

The constructor places a viewport container (with CSS class name bu-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 bu-container) and finally several subcontainers inside the previous ones, one per each view with same column value (with a CSS class name bu-subcontainer). This simple but powerful method allow the creation of complex layouts.


new Workspace(options)

Parameters:
Name Type Description
options bu.WorkspaceOptions

Workspace options.

Source:
bu/workspace.js
Fires:
  • ol.Object.Event#event:change:layout
  • ol.Object.Event#event:change:size
  • ol.Object.Event#event:change:target

Extends

  • ol.Object

Members


actions :Array.<bu.action.Action>

Type:
Source:
bu/workspace.js

containers :Array.<Element>

Type:
  • Array.<Element>
Source:
bu/workspace.js

controls :Array.<bu.control.Control>

Type:
Source:
bu/workspace.js

layout :bu.Layout

Type:
Source:
bu/workspace.js

subcontainers :Array.<Element>

Type:
  • Array.<Element>
Source:
bu/workspace.js

viewers :Array.<bu.Viewer>

Type:
Source:
bu/workspace.js

Methods


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:
bu/workspace.js

getLayout()

Gets the layout.

Source:
bu/workspace.js
Returns:

The current layout.

Type
bu.Layout

getSize()

Get the size of this workspace.

Source:
bu/workspace.js
Returns:

The size in pixels of the workspace in the DOM.

Type
bu.Size | undefined

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:
bu/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:
bu/workspace.js
Returns:

The element that the workspace is rendered in.

Type
Element

setSize(size)

Set the size of this workspace.

Parameters:
Name Type Description
size bu.Size | undefined

The size in pixels of the workspace in the DOM.

Source:
bu/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:
bu/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:
bu/workspace.js