Using jQuery

Using jQuery is also supported when working with the 2D Viewer API.

For legacy reasons small differences exist in the way you interact with the 2D Viewer when using jQuery.

Installation

1. Add jQuery to your project

Include jQuery in your HTML file using a script tag.

HTML


2. Add the 2D Viewer to your project

Include the 2D Viewer in your HTML file using a script tag, this will add the global bimsync object to the window object.

HTML


3. Provide a container for the 2D Viewer

Create a div element for attaching a 2D Viewer instance to.

HTML


4. Initialize the 2D Viewer API

Set a callback function and then invoke the loadViewer2d method, the 2D Viewer is ready once callback invoked.

JS


5. Create a 2D Viewer instance

Initialize the 2D Viewer by invoking the viewer2d method on the jQuery object for the div where you want to attach the 2D Viewer.

JS


6. Interact with the 2D Viewer

Call methods on the 2D Viewer instance to interact with the 2D Viewer.

JS


Usage

HTML


Options

The options for the 2D Viewer are the same when using jQuery but the default value may differ.

Properties

Name

Type

Default

Description

hoverSpaces

Boolean

true

Whether mouse hover highlights space below the cursor

showViewpoint

Boolean

true

Sets viewpoint visibility

selectColor

String

#a7f555

Sets the CSS color of selected objects

Methods

In general, the methods are the same when using jQuery but the way you call them is different.

JS


Some methods are also available under their deprecated names.

Method

Deprecated Names

getStoreyByElevation

storeyByElevation

getStoreys

storeys

hideStoreys

hidestoreys

moveTo

moveto

showStorey

showstorey

transformModel

setTransformation

For legacy reasons some methods have different signatures when using jQuery.

captureScreenshot

When using jQuery the name for this method is screenshot.

Usage

JS


onScreenshot

Type

(imageData: String) => Void

loadUrl

When using jQuery the name for this method is loadUrlPromise.

Usage

JS


Events

Callbacks for 2D Viewer events may have different signatures when using jQuery. Each event documentation page details any differences.

Updated 07 Jun 2024
Did this page help you?