Seat Selector
The seat selector provides convenience wrappers to render a seat map in the browser. You can modify the behaviour and subscribe to certain callbacks to react to certain events e.g. a user selecting a seat in the map.
Initialize
Attributes
The id of the element to hold the map
The baseUrl of the seating backend service
https://seatmap.vivenu.com
https://seatmap.vivenu.dev
The ID of the seating event which holds the state.
Optional Attributes
Collapse all<html>
<body>
<div id="map"></div>
<script type="application/javascript" src="https://seatmap.vivenu.com/js/init.js"></script>
<script>
const instance = VIInit();
instance.initSeatSelector({
holder: "map",
baseUrl: "https://seatmap.vivenu.com",
eventId: "${EVENT_ID}",
options: options,
});
</script>
</body>
</html>
Options
Attributes
A configuration about categories for this event
The reference of the category. This ref is used to map ticketTypes to categories
This reference is used to map a category to a defined category in the seat map
The remaining sale volume for this category
A configuration about ticket types for this event
The reference of the category this ticket type belongs to
Whether the ticket type is active and can be purchased
The price of this particular ticket type
The remaining sale volume for this category
Optional Attributes
Collapse allOptional Attributes
Collapse all{"categories": [{"ref": "68355747-b7c0-4bc4-89c6-38af352e6de1","seatingReference": "6082a1ed75a4b008a1ad4659","v": 200}],"ticketTypes": [{"categoryRef": "68355747-b7c0-4bc4-89c6-38af352e6de1","active": true,"price": 54.99,"v": 200,"ignoredForStartingPrice": true}],"orphan": {"minSeatDistance": 1,"edgeSeatsOrphaning": true},"theme": "light","contingents": [],"allowSelectionOfUnavailableObjects": true,"highlightSeatsBlockedByContingent": true,"currency": "EUR","visibleLayers": ["layerid1","layerid2"],"preloadedMap": {}}
Seat Object
Attributes
The id of the seat. This id is used in the callbacks
Is used to determine the type of the object.
6
The Id of the seating category
The name of the row group where the seat is located
The name of the row where the seat is located
The seat name
An Id that holds the status of the seat. This id is used to reserve/book/free the seat
Optional Attributes
Collapse all{"_id": "string","_type": 6,"categoryId": "string","sectionName": "S","groupName": "G","rowName": "10","seatName": "55","statusId": "5e7aa965-27b7-4f44-97bd-f4eb62b15243","gate": "G-10","seatType": "handicapped","meta": {"key_1": "value_1","key_2": "value_2"}}
General Admission Object
Attributes
The id of the seat. This id is used in the callbacks
Is used to determine the type of the object.
7
The Id of the seating category
An Id that holds the status of the general admission. This id is used to reserve/book/free seats inside the GA
The name for the general admission
Optional Attributes
Collapse all{"_id": "string","_type": 7,"categoryId": "string","statusId": "f451e2a4-05a3-43e5-82c2-da5c6c9ecf3b","name": "Standing Block A","gate": "G-10","meta": {"key_1": "value_1","key_2": "value_2"}}
Callbacks
Event | Trigger |
---|---|
onObjectSelected | When an object gets selected. An object is either a Seat or a GeneralAdmission |
onObjectDeselected | When a Seat gets deselected. This event does not apply to GeneralAdmission |
onSelectionValid | When a selection get validated and is valid |
onSelectionInvalid | When a selection get validated and is invalid. Example for an invalid selection is when the selected seats do not satisfy orphanage constraints |
onLoadDone | When the initial loading of the Seatmap is done |
onObjectSelected
This event occurs when an object gets selected. An object can be of type Seat
and of type GeneralAdmission
.
/**
* This event occurs when an object gets selected.
* @param {string} type - The type of the event. "onObjectSelected"
* @param {string} id - The id of the object which got selected
* @param {SeatInfo|GeneralAdmissionInfo} - resource The resource
*/
const onObjectSelected = (type, id, resource) => {
console.log(id);
console.log(resource);
}
onObjectDeselected
This event occurs when an Seat
gets deselected.
Caution: This event does not apply to GeneralAdmission
. General admission can only be deselected through the setSelectedObjects method.
/**
* This event occurs when an object gets selected.
* @param {string} type - The type of the event. "onObjectDeselected"
* @param {string} id - The id of the object which got selected
* @param {SeatInfo} resource - The resource
*/
const onObjectDeselected = (type, id, resource) => {
console.log(id);
console.log(resource);
}
onSelectionInvalid
When a selection get validated and is invalid. Example for an invalid selection is when the selected seats do not satisfy orphanage constraints
interface Violations {
orphans?: SeatInfo[];
}
/**
* The event occurs when a selection get validated and is invalid
* @param {string} type - The type of the event. "onSelectionInvalid"
* @param {Violations} violations - An object containing information about invalid selection
*/
const onSelectionInvalid = (type, violations) => {
console.log(violations);
if (violations.orphans) {
console.log("There are orphans in your current selection");
console.log(violations.orphans);
}
}
Set selected objects
You can update the selection of the user with calling the function selectObjectsInSeatSelector
on the VIInit
instance.
Notice: You need to call this function in order to get a general admission deselected.
/**
* Set the objects of the user selection
* @param {Array<string>} ids - An array of Object-IDs to be selected
*/
selectObjectsInSeatSelector(ids: string[]): void;
Set categories
You can update the configuration of the category and their availabilities with calling the function setCategories
on the VIInit
instance.
Notice: Please make sure that you call this function after initialization is done.
/**
* Set the category configuration
* @param {Array<SeatMapCategory>} categories - An array of categories
*/
setCategories(categories: SeatMapCategories[]): void;
Get best available seats
Through this function you can get the best available seats on the map. This function takes key-value pairs as parameters, where the key is the categoryRef
and the value is the requested amount of seats in this category.
The function returns key-value pairs, where the key is the categoryRef
and the value is array of SeatInfoResource.
Notice: Best available seats are calculated by the distance to the focal point. If a focal point does not exist on the map then the center of the map is considered as the focal point.
interface BestAvailableSeatsParams {
[categoryRef: string]: number
}
interface BestAvailableSeatsResponse {
[categoryRef: string]: SeatInfoResource[]
}
/**
* Get best available seats
* @param {BestAvailableSeatsParams}
*/
getBestAvailableSeats(params: BestAvailableSeatsParams): Promise<BestAvailableSeatsResponse>;
Get view from seat
Through this function you can get the closest viewpoint to a seat. This function takes the seat id as a parameter. The function returns the closest viewpoint to the seat, if the seatmap has atleast one viewpoint placed on the seats layer. Otherwise it returns undefined.
interface ViewPoint {
_id: string
_type: number
imageType: ImageType
image: string
}
/**
* Get view from seat
* @param {string} seatId - The id of the seat
*/
getViewFromSeat(seatId: string): Promise<ViewPoint | undefined>;