Class: Viewer

bu.oblique. Viewer

This is a 2D viewer class that uses internally a ol.Map class from OpenLayers to show oblique imagery and vector data on top of it. Note that with bu.oblique.Viewer and all its subclasses, any property set in the options is set as a ol.Object property on the viewer object, so is observable, and has get/set accessors.


new Viewer(options)

Parameters:
Name Type Description
options bu.oblique.ViewerOptions

Viewer options.

Source:
bu-oblique/obliqueviewer.js
Fires:

Extends

Members


extraZoomLevels :number|undefined

This property represents the number of zoom levels to add to existing zoom levels defined in any oblique image. In the new zoom levels the tiles will be rescaled.

Type:
  • number | undefined
Source:
bu-oblique/obliqueviewer.js

map :ol.Map

Type:
  • ol.Map
Source:
bu-oblique/obliqueviewer.js

state :bu.ViewerState

Type:
Inherited From:
Source:
bu/viewer.js

useAnimations :boolean

Type:
  • boolean
Source:
bu-oblique/obliqueviewer.js

viewType :bu.ViewType|undefined

Type:
Overrides:
Source:
bu-oblique/obliqueviewer.js

Methods


addLayer(layer)

Adds the given layer to the top of this viewer. If you want to add a layer elsewhere in the stack, use getLayers() and the methods available on ol.Collection.

Parameters:
Name Type Description
layer ol.layer.Base

Layer.

Inherited From:
Source:
bu/viewer.js

animate(var_args)

Animate the viewer if an oblique image is loaded. The viewer's center, zoom (or resolution), and rotation can be animated for smooth transitions between viewer states. For example, to animate the viewer to a new zoom level:

viewer.animate({zoom: viewer.getZoom() + 1});

By default, the animation lasts one second and uses in-and-out easing. You can customize this behavior by including duration (in milliseconds) and easing options (see ol.easing).

To chain together multiple animations, call the method with multiple animation objects. For example, to first zoom and then pan:

viewer.animate({zoom: 10}, {center: [0, 0]});

If you provide a function as the last argument to the animate method, it will get called at the end of an animation series. The callback will be called with true if the animation series completed on its own or false if it was cancelled.

Animations are cancelled by user interactions (e.g. dragging the map) or by calling viewer.setCenter(), viewer.setResolution(), or viewer.setRotation() (or another method that calls one of these).

Coordinates for the center animations must always be in pixels of current oblique following the same restrictions that setPixelCenter method has.

Rotations for the rotation animations must always be in decimal degrees with values [0, 360) following the same restrictions that setRotation method has.

Parameters:
Name Type Argument Description
var_args olx.AnimationOptions | function <repeatable>

Animation options. Multiple animations can be run in series by passing multiple options objects. To run multiple animations in parallel, call the method multiple times. An optional callback can be provided as a final argument. The callback will be called with a boolean indicating whether the animation completed without being cancelled.

Source:
bu-oblique/obliqueviewer.js

clone()

Clones this viewer reinitializing the new one with main values of current one.

Overrides:
Source:
bu-oblique/obliqueviewer.js
Returns:

The viewer cloned.

Type
bu.oblique.Viewer

constrainResolution(resolution [, opt_delta] [, opt_direction])

Get the constrained resolution of this viewer.

Parameters:
Name Type Argument Description
resolution number | undefined

Resolution.

opt_delta number <optional>

Delta. Default is 0.

opt_direction number <optional>

Direction. Default is 0.

Source:
bu-oblique/obliqueviewer.js
Returns:

Constrained resolution.

Type
number | undefined

getAttributions()

Returns the list of ol.Attribution currently visible in the viewer.

Inherited From:
Overrides:
Source:
bu/viewer.js
Returns:

Attributions.

Type
Array.<Object.<string, ol.Attribution>>

getCenter()

Returns the current center of the viewer. Coordinates are always in WGS84 latlon, first value in the coordinate is longitude and second latitude. Returns null if no center has been set.

Source:
bu-oblique/obliqueviewer.js
Returns:

The viewer center.

Type
bu.Coordinate

getCrosshair()

Get the element that serves as a mid crosshair in the viewer, useful for debugging purposes.

Inherited From:
Source:
bu/viewer.js
Returns:

The viewer overlay that shows the crosshair.

Type
Element

getCurrentPanoramaID(viewIndex)

Gets the current panorama ID for a given bu.street.Viewer identified by its viewIndex inside the workspace layout.

Parameters:
Name Type Description
viewIndex number

The index inside of the workpace layout that identifies the street viewer for which the ID is set.

Source:
bu-oblique/obliqueviewer.js
Returns:

The ID of the panorama.

Type
string

getDebugGrid()

Returns if the debug grid should be visible or not when debug mode is true.

Inherited From:
Source:
bu/viewer.js
Returns:

If visible or not.

Type
boolean

getDebugMode()

Returns the current debug mode of the viewer. If true then the debug mode is activated. Debug mode is a special mode that show extra information in the viewer of tiles and other tools that are useful when debugging. Initially any viewer uses the global bu.DEBUG property to set if debug mode must be used. The initial value could later be change through this property.

Inherited From:
Source:
bu/viewer.js
Returns:

The debug mode.

Type
boolean

getImage()

Returns the current oblique image. It returns null if no image is currently loaded.

Source:
bu-oblique/obliqueviewer.js
Returns:

The image.

Type
bu.oblique.Image | null

getImageID()

Returns the image ID of the BlomURBEX oblique image currently loaded.

Source:
bu-oblique/obliqueviewer.js
Returns:

The image ID.

Type
string

getLastCenter()

Returns the last center fo the last not null image loaded. Returns null if an image never was loaded.

Source:
bu-oblique/obliqueviewer.js
Returns:
Type
bu.ObliqueMetadata

getLayer()

Returns the current layer of the viewer. The layer in which search for images. Each layer represents a different set of images in the server.

Source:
bu-oblique/obliqueviewer.js
Returns:

The viewer layer.

Type
string

getLayerGroup()

Get the layergroup associated with this viewer.

Inherited From:
Overrides:
Source:
bu/viewer.js
Returns:

A layer group containing the layers in this viewer.

Type
ol.layer.Group

getLayers()

Get the collection of layers associated with this viewer.

Inherited From:
Source:
bu/viewer.js
Returns:

Layers.

Type
ol.Collection.<ol.layer.Base>

getLoadedImage()

Returns the currently loaded image or null if no one is loaded.

Source:
bu-oblique/obliqueviewer.js
Returns:
Type
bu.oblique.Image

getMaxResolution()

Returns the current maximum resolution of the viewer or null if the viewer still has no image loaded.

Source:
bu-oblique/obliqueviewer.js
Returns:

The viewer maximum resolution in meters per pixel.

Type
number

getMaxZoom()

Returns the maximum zoom of the viewer.

Source:
bu-oblique/obliqueviewer.js
Returns:

The maximum zoom of the viewer.

Type
number

getMinResolution()

Returns the current minimum resolution of the viewer or null if the viewer still has no image loaded.

Source:
bu-oblique/obliqueviewer.js
Returns:

The viewer minimum resolution in meters per pixel.

Type
number

getMinZoom()

Returns the minimum zoom of the viewer.

Source:
bu-oblique/obliqueviewer.js
Returns:

The minimum zoom of the viewer.

Type
number

getOverlayContainerStopEvent()

Get the element that serves as a container for overlays that don't allow event propagation. Elements added to this container won't let mousedown and touchstart events through to the viewer, so clicks and gestures on an overlay don't trigger any event.

Inherited From:
Source:
bu/viewer.js
Returns:

The viewer's overlay container that stops events.

Type
Element

getResolution()

Returns the current resolution of the viewer or null if the viewer still has no image loaded.

Source:
bu-oblique/obliqueviewer.js
Returns:

The viewer resolution in meters per pixel.

Type
number

getResolutions()

Returns the resolutions of the viewer.

Source:
bu-oblique/obliqueviewer.js
Returns:

The resolutions of the viewer.

Type
Array.<number>

getRotation()

Returns the rotation of the viewer. Zero means looking north, 90 looking west, etc. Values should be inside [0, 360).

Source:
bu-oblique/obliqueviewer.js
Returns:

The rotation of the viewer in decimal degrees.

Type
number

getSize()

Get the size of this viewer.

Inherited From:
Source:
bu/viewer.js
Returns:

The size in pixels of the viewer in the DOM.

Type
bu.Size | undefined

getState()

Return the viewer state.

Overrides:
Source:
bu-oblique/obliqueviewer.js
Returns:
Type
bu.ViewerState

getTarget()

Get the target in which the viewer 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.

Inherited From:
Source:
bu/viewer.js
Returns:

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

Type
Element | string | undefined

getTargetElement()

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

Inherited From:
Source:
bu/viewer.js
Returns:

The element that the viewer is rendered in.

Type
Element

getTime()

Returns the current time filter of the viewer. Valid time values are any string with pattern YYYYMMDD or with pattern YYYYMMDD-YYYYMMDD. First filters images before the date, and second filters images between the dates.

Inherited From:
Source:
bu/viewer.js
Returns:

The time string.

Type
string

getTimeValues()

Returns the current time value as a pair of values [minDate,maxDate]. If time value has pattern YYYYMMDD then minDate = -Infinity and maxDate a number with 8 digits following YYYYMMDD pattern. If time value has pattern YYYYMMDD-YYYYMMDD then minDate and maxDate are numbers with 8 digits following YYYYMMDD pattern. If time value is not valid pattern then null is returned.

Inherited From:
Source:
bu/viewer.js
Returns:

The time as a pair of values.

Type
Array.<number>

getUsePanoramas()

Returns if oblique viewer must use panoramas. If true a vector layer rendering panoramas will be shown on top and interactions with the layer will trigger a search for near panoramas.

Source:
bu-oblique/obliqueviewer.js
Returns:

The value of the property.

Type
boolean

getViewport()

Return the viewport of the viewer.

Inherited From:
Source:
bu/viewer.js
Returns:

The viewport.

Type
Element

getViewType()

Return the type of the viewer.

Inherited From:
Source:
bu/viewer.js
Returns:

The viewer type.

Type
bu.ViewType

getZoom()

Returns the zoom of the viewer.

Source:
bu-oblique/obliqueviewer.js
Returns:

The zoom of the viewer.

Type
number

openImage(image)

Opens image.

Parameters:
Name Type Description
image bu.oblique.Image

The oblique metadata.

Source:
bu-oblique/obliqueviewer.js

removeLayer(layer)

Removes the given layer from this viewer.

Parameters:
Name Type Description
layer ol.layer.Base

Layer.

Inherited From:
Source:
bu/viewer.js
Returns:

The removed layer (or undefined if the layer was not found).

Type
ol.layer.Base | undefined

render()

Renders the viewer.

Inherited From:
Overrides:
Source:
bu/viewer.js

setCenter(center, done)

Sets the current center of the viewer. Coordinates are always in WGS84 latlon, first value in the coordinate is longitude and second latitude.

Parameters:
Name Type Description
center bu.Coordinate

The new center for the viewer in WGS84 latlon.

done function | undefined

An optional function to call when recentering ends. The function will receive the oblique image finally loaded or null if no image was loaded. Default is a function that does nothing.

Source:
bu-oblique/obliqueviewer.js

setCrosshairVisibility(visible)

Sets the crosshair visibility.

Parameters:
Name Type Description
visible boolean

If visible or not.

Inherited From:
Source:
bu/viewer.js

setCurrentPanoramaID(viewIndex, id)

Sets the current panorama ID for a given bu.street.Viewer identified by its viewIndex inside the workspace layout. When this value is set if a bu.oblique.layer.Panoramas is used inside the viewer it will show the current panorama in a highlighted color.

Parameters:
Name Type Description
viewIndex number

The index inside of the workpace layout that identifies the street viewer for which the ID is set.

id string

The ID of the panorama.

Source:
bu-oblique/obliqueviewer.js

setDebugGrid(visible)

Sets if the debug grid should be visible or not when debug mode is true.

Parameters:
Name Type Description
visible boolean

If visible or not.

Inherited From:
Source:
bu/viewer.js

setDebugMode(debugmode)

Sets the debug mode of the viewer. If true then the debug mode is activated. Debug mode is a special mode that show extra information in the viewer of tiles and other tools that are useful when debugging. Initially any viewer uses the global bu.DEBUG property so set if debug mode must be used. The initial value could later be change through this property.

Parameters:
Name Type Description
debugmode boolean

The debug mode.

Inherited From:
Source:
bu/viewer.js

setImage(image)

Sets the BlomURBEX oblique metadata to be shown.

Parameters:
Name Type Description
image bu.oblique.Image

The oblique metadata.

Source:
bu-oblique/obliqueviewer.js

setImageID(imageid)

Sets the image ID of the BlomURBEX oblique image to be shown.

Parameters:
Name Type Description
imageid string

The image ID.

Source:
bu-oblique/obliqueviewer.js

setLayer(layer)

Returns the current layer of the viewer. The layer in which search for images. Each layer represents a different set of images in the server.

Parameters:
Name Type Description
layer string

The viewer layer.

Source:
bu-oblique/obliqueviewer.js

setLayerGroup(layerGroup)

Sets the layergroup of the viewer.

Parameters:
Name Type Description
layerGroup ol.layer.Group

A layer group containing the layers in the viewer.

Inherited From:
Overrides:
Source:
bu/viewer.js

setPixelCenter(pixelCenter)

Sets the center of the viewer to a given pixel.

Parameters:
Name Type Description
pixelCenter bu.Coordinate

The new pixel center for the viewer.

Source:
bu-oblique/obliqueviewer.js

setResolution(resolution)

Sets the resolution of the viewer. As a change in resolution is not an async operation a done function is not needed here as for setCenter or setRotation.

Parameters:
Name Type Description
resolution number

The new resolution for the viewer in meters per pixel.

Source:
bu-oblique/obliqueviewer.js

setRotation(rotation [, request], done)

Set the rotation of the viewer. Zero means looking north, 90 looking west, etc. Values should be inside [0, 360).

Parameters:
Name Type Argument Description
rotation number

The new rotation for the viewer in decimal degrees.

request boolean <optional>

If force a request or just rotate without a request.

done function | undefined

An optional function to call when the rotation ends. The function will receive the oblique image finally loaded or null if no image was loaded. Default is a function that does nothing.

Source:
bu-oblique/obliqueviewer.js

setSize(size)

Set the size of this viewer.

Parameters:
Name Type Description
size bu.Size | undefined

The size in pixels of the viewer in the DOM.

Inherited From:
Source:
bu/viewer.js

setSyncingHandlers(handler)

Sets the listeners to the events of the viewer that will cause other synced viewers to be updated. This is an abstract method. It must be overriden in derived classes.

Parameters:
Name Type Description
handler function

The handler that will manage the events.

Inherited From:
Overrides:
Source:
bu/viewer.js
Returns:

Array of key listeners for later easy disposal.

Type
Array.<ol.EventsKey>

setTarget(target)

Set the target element to render this viewer into.

Parameters:
Name Type Description
target Element | string | undefined

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

Inherited From:
Source:
bu/viewer.js

setTime(time)

Sets the current time filter of the viewer. Valid time values are any string with pattern YYYYMMDD or with pattern YYYYMMDD-YYYYMMDD. First filters images before the date, and second filters images between the dates.

Parameters:
Name Type Description
time string

The time string.

Inherited From:
Source:
bu/viewer.js

setUsePanoramas(use)

Sets if oblique viewer must use panoramas. If true a vector layer rendering panoramas will be shown on top and interactions with the layer will trigger a search for near panoramas.

Parameters:
Name Type Description
use boolean

The value of the property.

Source:
bu-oblique/obliqueviewer.js

setZoom(zoom)

Set the zoom of the viewer.

Parameters:
Name Type Description
zoom number

The zoom of the viewer.

Source:
bu-oblique/obliqueviewer.js

setZoomToExtent(layer)

Set the zoom and center of the viewer to cover the extent of a given layer.

Parameters:
Name Type Description
layer ol.layer.Vector

The layer to zoom at. The layer must be one of the current added layers and the source must be an instance of bu.source.Vector.

Source:
bu-oblique/obliqueviewer.js

syncWithViewer(viewer, viewIndex, syncProperties, event)

Synchronizes this viewer with another one knowing its viewIndex and its sync options.

Parameters:
Name Type Description
viewer bu.Viewer

The viewer to sync with.

viewIndex number

The index in the layout of the viewer to sync with.

syncProperties bu.SyncProperties

The syncing properties.

event ol.events.Event

The event that triggered the syncing action.

Inherited From:
Overrides:
Source:
bu/viewer.js

toPixelCenter(center)

Returns a promise object that converts from world center to pixel center inside current image.

Parameters:
Name Type Description
center bu.Coordinate

The new center for the viewer in WGS84 latlon. first value in the coordinate is longitude and second latitude.

Source:
bu-oblique/obliqueviewer.js
Returns:

Promise object with a resolve function that receives an object and a reject function that receives an Error. The object for the resolve function has two keys: pixelCenter with the center transformed to oblique image pixel coordinates, and isInside with a boolean indicating if the pixelCenter is inside current image.

Type
Promise

updateImage(image)

Opens image if already set or sets image if not.

Parameters:
Name Type Description
image bu.oblique.Image

The oblique image.

Source:
bu-oblique/obliqueviewer.js

updateSize()

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

Inherited From:
Source:
bu/viewer.js

updateViewer(center, rotation, time, layer)

Returns a Promise that updates the viewer with current set values. Any value passed can be null. In that case the current available value will be used.

Parameters:
Name Type Argument Description
center bu.Coordinate <nullable>

Center for the viewer in WGS84 LonLat coordinates.

rotation number <nullable>

Rotation for the viewer in decimal degrees.

time string <nullable>

Time filter as specified in the observable property.

layer string <nullable>

Layer filter as specified in the observable property.

Source:
bu-oblique/obliqueviewer.js
Returns:

A Promise that for the resolve function returns the bu.oblique.Image object that has been loaded when updating the viewer or null if no image was loaded, and that never rejects with an error. In case of error it calls the resolve function with a null value.

Type
Promise

zoomByDelta(delta, duration)

Zooms the viewer the number of zoom levels defined by delta.

Parameters:
Name Type Description
delta number

Delta zoom levels.

duration number

Duration of animation in miliseconds.

Source:
bu-oblique/obliqueviewer.js