API Reference | FloorsJS API | 2GIS Documentation
FloorsJS API
Parameter Required Description
width yes Widget width. Can be specified in pixels or percentage.
height yes Widget height. Can be specified in pixels or percentage.
container no The element inside which to create the widget. You can pass either the element itself or its id. If this parameter is not specified, the widget will be created where the initialization code is located (using document.write).
initData yes Data to initialize the widget.
Parameter Required Description
complexId yes The id of the building whose floors need to be displayed.
options no Widget options.
Parameter Description Default value
locale Widget interface locale. Available values: ru_RU, es_CL, or en_US. ru_RU
initialSearchQuery Initializes the widget with an open search results page for the given query. undefined
initialRubric Initializes the widget with an open list of firms in the rubric with the given id. undefined
initialFirm Initializes the widget with an open firm card with the given id. undefined
initialZoom Determines the zoom level at which to open the widget. If not specified, the zoom level is chosen automatically to fit the entire building inside the widget. This parameter is ignored if either initialSearchQuery or initialRubric is specified. undefined
initialRotation Determines the angle to which to rotate the map on which to open the widget. Specified in radians. If not specified, the angle is chosen automatically. undefined
initialFloor Determines the floor to which to open the widget. If not specified, the widget opens on the building's default floor. undefined
rotatable Determines whether the map with floors can be rotated. true
minZoom Determines the map's minimum zoom level. If not specified, it is calculated automatically. undefined
maxZoom Determines the map's maximum zoom level. If not specified, it is calculated automatically. undefined

The DG.FloorsWidget.init method returns an object with three callable methods.

Method Description
search(query) Opens a search results page for the specified query.
showFirm(firmId) Opens a firm card with the given id.
showRubric(rubricId) Opens a list of firms in the rubric with the given id.
zoomIn() Increases the map zoom level.
zoomOut() Decreases the map zoom level.
showFloor(floor) Switches the map to the floor with the given name. Accepts a string with the floor name.

The widget object generates events that you can subscribe to. The following methods control events:

Method Description
on(type, handler) Adds the handler event handler for the type event.
off(type, handler) Removes the handler event handler for the type event.
off(type) Removes all handlers for the type event.
off() Removes all handlers for all events.

You can subscribe to the following events:

Name Description Data received in the event
init Occurs at the moment the map is initialized. floorList, firmList
click Occurs when the user clicks on a firm (room or icon) on the map. firmIds
zoomend Occurs at the end of the zoom animation. state
floorswitch Occurs when the floor is switched. state

floorList

An array that contains the names of all floors in the building, starting from the lowest to the highest.

firmList

An array containing all firms in the building. The array element is an object with the following fields:

Name Type Description
id string The firm's id.
floor string The name of the floor on which the firm is located.

state

An object that contains data about the current state of the map. It has the following fields:

Name Type Description
floor string The current floor's name.
zoom number The current map zoom level.
minZoom number The map's minimum zoom level.
maxZoom number The map's maximum zoom level.

firmIds

An array of firm ids where the click was made. Cannot be empty. May have more than one element if the click was made in a room containing multiple firms.