L.Wrld.map.indoors
function onEnter(event) {
console.log("Entered indoor map: " + event.indoorMap.getIndoorMapName());
}
function onExit(event) {
console.log("Exited indoor map");
}
map.indoors.on("indoormapenter", onEnter);
map.indoors.on("indoormapexit", onExit)
Methods
map.indoors.isIndoors()
Returns a boolean
indicating whether an indoor map is currently being viewed.
map.indoors.enter(indoorMap)
Move the camera into an indoor map.
Argument | Type | Description |
---|---|---|
indoorMap | IndoorMapEntrance | IndoorMap | string |
The entrance to an indoor map to enter, or the indoor map itself, or the ID of the map as a string |
map.indoors.exit()
When viewing an indoor map, exits back to the exterior view.
map.indoors.getActiveIndoorMap()
Returns the IndoorMap
currently being viewed, or null
if not viewing an indoor map at all.
map.indoors.getFloor()
Returns an IndoorMapFloor
representing the current floor of the active indoor map, or null
if not viewing an indoor map.
map.indoors.setFloor(floor)
Sets the current floor to display within the active indoor map. Returns a boolean
indicating whether the floor was successfully set.
Argument | Type | Description |
---|---|---|
floor | IndoorMapFloor | string | number |
The floor to view, or the ID of that floor, or the index of that floor |
map.indoors.moveUp(numberOfFloors)
View a floor some number of floors above than the current floor.
Argument | Type | Description |
---|---|---|
numberOfFloors | number | How many floors to move up. Defaults to 1 |
map.indoors.moveDown(numberOfFloors)
View a floor some number of floors below than the current floor.
Argument | Type | Description |
---|---|---|
numberOfFloors | number | How many floors to move down. Defaults to 1 |
map.indoors.expand()
Transition to an expanded view of the indoor map, showing all floors.
map.indoors.collapse()
When expanded, transition back to the normal, collapsed view of an indoor map.
map.indoors.setFloorInterpolation(value)
When expanded, can be used to smoothly interpolate between the floors in view. A value of 0 will put the bottom floor in focus, while a value of 1 will put the top floor in focus.
Argument | Type | Description |
---|---|---|
value | number | An interpolation value between the bottom and top floors in the range 0..1 |
map.indoors.getFloorInterpolation()
Returns the current floor interpolation value.
map.indoors.setFloorFromInterpolation(interpolationValue)
Sets the current floor based on some interpolation value by rounding to the nearest floor. Returns a boolean
indicating success, as in setFloor()
.
Argument | Type | Description |
---|---|---|
interpolationValue | number | An interpolation value between the bottom and top floors in the range 0 to 1. Defaults to the current value of getFloorInterpolation() |
map.indoors.setEntityHighlights(ids, color)
Highlights one or more indoor entities.
Argument | Type | Description |
---|---|---|
ids | string | string[] | The id(s) of the entities |
color | number[] | The RGBA value of the highlight, stored in an array of numbers ranging from 0 to 255 |
map.indoors.clearEntityHighlights(ids)
Clears the highlights from one or more indoor entities. If no ids are specified then all highlighted entities will be cleared.
Argument | Type | Description |
---|---|---|
ids | string | string[] | The id(s) of the entities. (Optional) |
Events
You can subscribe to events relating to indoor maps by using [events methods] on this object.
For example:
map.indoors.on("indoormapenter", function(e) {
console.log("Entered an indoor map");
});
The following events are supported.
Event | Data | Description |
---|---|---|
indoormapenter | IndoorMapEvent | Fired when an IndoorMap is entered. |
indoormapexit | IndoorMapEvent | Fired when an IndoorMap is exited. |
indoormapfloorchange | IndoorFloorEvent | Fired when the IndoorMapFloor is set. |
indoorentranceadd | IndoorEntranceEvent | Fired when an IndoorMapEntrance becomes available. |
indoorentranceremove | IndoorEntranceEvent | Fired when an IndoorMapEntrance becomes unavailable. |
expandstart | Event | Fires when an indoor map starts expanding. See map.indoors.expand() . |
expand | Event | Fired repeatedly while an indoor map is expanding. |
expandend | Event | Fires when an indoor map stops expanding. |
collapsestart | Event | Fires when an indoor map starts collapsing. See map.indoors.collapse() . |
collapse | Event | Fired repeatedly while an indoor map is collapsing. |
collapseend | Event | Fires when an indoor map stops collapsing. |
indoorentityclick | Event | Fires when an indoor entity was clicked. |