📚API References

The Jakartowns JavaScript API enables integration of the Jakartowns digital twin into third-party web applications. The JavaScript script contains the API’s code, including all its functions and methods to manipulate the digital twin.

The API facilitates interaction with the digital twin by providing methods to set the position, rotation, tilt, and field of view of the view.

The API is applied to an HTML container within the web application page.

Once the API is retrieved, the create_jakartowns function is available to create an instance of the Jakartowns digital twin in a specific container on the web page.

window.jakartowns.app.create_jakartowns('#app', options, callback)

This function is responsible for creating the Jakartowns digital twin in the specified container, with the given configuration options, and executes the callback function once the digital twin is ready for use. This allows developers to interact with the digital twin and customize its behavior according to specific needs.

Here’s a detailed explanation of each parameter of this function:

  1. '#app': This is the CSS selector of the HTML element where you want to display the digital twin. In this case, the element with the ID "app" will be used as the container for the digital twin.

  2. options: This is a JavaScript object containing configuration options for the digital twin. These options control whether the digital twin’s header and mini-map are enabled or disabled.

  3. callback: This is a callback function that is called once the digital twin instance is created and ready for use. The callback function can be defined as an anonymous function (arrow function) that takes a viewer parameter. The viewer parameter corresponds to the created digital twin instance. You can use this instance to perform specific actions and operations on the digital twin, such as adding listeners for position, rotation, tilt, and FOV update events.

Functions to Interact with the Digital Twin

setPosition(viewer, wantedPosition: { latitude: float, longitude: float })

Sets the view’s position of the digital twin on the map using the specified latitude and longitude coordinates. This function returns the digital twin’s data after positioning, including the current image UID and the distance between the target position and the panorama position.

setTilt(viewer, wantedTilt: int)

Sets the vertical tilt of the digital twin’s view using the specified value. This function returns the new tilt.

setPan(viewer, wantedPan: int)

Sets the horizontal rotation of the digital twin’s view using the specified value. This function returns the new rotation.

setFov(viewer, wantedFov: int)

Sets the field of view (FOV) of the digital twin’s view using the specified value. This function returns the new FOV value.

Events

position

This event is triggered when the user changes position in the digital twin. It provides the details of the new position, including latitude and longitude coordinates.

rotation

This event is triggered when the user changes the horizontal rotation of the digital twin’s view. It provides the new rotation value.

tilt

This event is triggered when the user changes the vertical tilt of the digital twin’s view. It provides the new tilt value.

fov

This event is triggered when the user changes the field of view (FOV) of the digital twin’s view. It provides the new FOV value.

Last updated