### Complete HTML Example for Indoor 3D Map
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
A full HTML example demonstrating the setup of the indoor3D map, including necessary script includes, basic styling, map initialization, data loading, and UI configuration.
```html
Indoor 3D Map
```
--------------------------------
### Basic Indoor Map Implementation
Source: https://github.com/wolfwind521/indoor3d/blob/master/README.md
A minimal setup for initializing an indoor map and loading data.
```html
```
--------------------------------
### Advanced Indoor Map Configuration
Source: https://github.com/wolfwind521/indoor3d/blob/master/README.md
A more complex example demonstrating custom container IDs, 3D mode, and UI integration.
```html
```
--------------------------------
### Map Initialization Parameters
Source: https://github.com/wolfwind521/indoor3d/blob/master/README.md
Setting up map parameters and creating the map instance.
```javascript
var params={mapDiv:"indoor3d",dim:"3d"};
var indoorMap = IndoorMap(params);
```
```javascript
var indoorMap = IndoorMap();
```
--------------------------------
### Required Library Includes
Source: https://github.com/wolfwind521/indoor3d/blob/master/README.md
The necessary JavaScript and CSS files required to initialize the Indoor3D environment.
```html
```
--------------------------------
### Create IndoorMap Instance
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Instantiates an IndoorMap object. Configure the map container, rendering dimension (2D/3D), or specific dimensions.
```javascript
var map = new IndoorMap();
```
```javascript
var params = {
mapDiv: "indoor3d", // ID of the container div
dim: "2d" // "2d" or "3d" (default: "3d")
};
var map = new IndoorMap(params);
```
```javascript
var params = {
size: [800, 500] // [width, height] in pixels
};
var map = new IndoorMap(params);
```
--------------------------------
### Load and Configure Map Data
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Loads map data from a JSON file and initializes the map. Use the callback to configure map settings after data is loaded.
```javascript
var map = new IndoorMap({ mapDiv: "indoor3d", dim: "3d" });
map.load('data/mallMapData.json', function() {
// Data loaded, now configure the map
map.showAllFloors()
.showAreaNames(true)
.setSelectable(true);
// Add floor switching UI
var floorUI = IndoorMap.getUI(map);
document.body.appendChild(floorUI);
});
```
--------------------------------
### IndoorMap Constructor
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Initializes a new indoor map instance with optional configuration for the container and rendering dimensions.
```APIDOC
## new IndoorMap(params)
### Description
Creates a new indoor map instance. Accepts an optional parameters object to configure the map container and rendering dimension.
### Parameters
#### Request Body
- **mapDiv** (string) - Optional - ID of the container div.
- **dim** (string) - Optional - Rendering mode: "2d" or "3d" (default: "3d").
- **size** (array) - Optional - Array of [width, height] in pixels.
### Request Example
{
"mapDiv": "indoor3d",
"dim": "2d",
"size": [800, 500]
}
```
--------------------------------
### Accessing Mall Object Data with IndoorMap
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Demonstrates how to access building and floor information using the 'mall' property after the map data has been loaded. This includes retrieving IDs, counts, and specific floor details.
```javascript
var map = new IndoorMap({ mapDiv: "indoor3d" });
map.load('data/mallMapData.json', function() {
var mall = map.mall;
// Get building information
var buildingId = mall.getBuildingId();
var defaultFloorId = mall.getDefaultFloorId();
var floorCount = mall.getFloorNum();
// Get floor information
var currentFloorId = mall.getCurFloorId();
var currentFloor = mall.getCurFloor();
var specificFloor = mall.getFloor(2);
var floorByName = mall.getFloorByName("F1");
// Access raw JSON data
var floorJson = mall.getFloorJson(1);
console.log("Floor name:", floorJson.Name);
console.log("Rooms:", floorJson.FuncAreas.length);
console.log("Public points:", floorJson.PubPoint.length);
// Access all floors array
mall.floors.forEach(function(floor) {
console.log("Floor ID:", floor._id);
});
});
```
--------------------------------
### Map Loading and Parsing
Source: https://github.com/wolfwind521/indoor3d/blob/master/README.md
Methods for initializing the map data from files or JSON objects.
```APIDOC
## .load(fileName, callback)
### Description
Loads a map file. The callback function is executed upon completion. The getUI() function must be called within this callback.
### Parameters
- **fileName** (string) - Required - The path or name of the file to load.
- **callback** (function) - Required - Function to execute after loading.
## .parse(jsonData)
### Description
Parses JSON data directly if the data has already been loaded by other modules.
### Parameters
- **jsonData** (object) - Required - The map data object.
```
--------------------------------
### Initialize and Load Indoor Map
Source: https://github.com/wolfwind521/indoor3d/blob/master/index.html
Initializes the map container and loads map data from a JSON file. Requires a valid div ID and data source path.
```javascript
var params = { mapDiv:"indoor3d", dim:"2d" } var map = IndoorMap(params); map.load('data/testMapData.json', function(){ //map.setTheme(testTheme); map.showAreaNames(true).setSelectable(true); var ul = IndoorMap.getUI(map); document.body.appendChild(ul); });
```
--------------------------------
### Implement Floor Switching UI
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Retrieve the floor UI component using IndoorMap.getUI and append it to the DOM. CSS can be used to style the generated list elements.
```javascript
var map = new IndoorMap({ mapDiv: "indoor3d", dim: "3d" });
map.load('data/mallMapData.json', function() {
map.showAllFloors().setSelectable(true);
// Get the floor UI (returns a
element)
var floorUI = IndoorMap.getUI(map);
// Style the UI with CSS class 'floorsUI'
document.body.appendChild(floorUI);
// The UI includes:
// - "All" button (3D mode only) - shows all floors stacked
// - Individual floor buttons (F1, F2, B1, etc.)
});
```
```css
.floorsUI {
position: absolute;
right: 20px;
top: 50%;
list-style: none;
padding: 0;
}
.floorsUI li {
background: #fff;
padding: 10px 15px;
margin: 5px 0;
cursor: pointer;
border-radius: 4px;
}
.floorsUI li.selected {
background: #4CAF50;
color: white;
}
```
--------------------------------
### Room Selection Handling
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Enables user interaction with rooms for selection. Set a listener to handle selection events and programmatically select rooms by ID.
```javascript
var map = new IndoorMap({ mapDiv: "indoor3d" });
map.load('data/mallMapData.json', function() {
map.showFloor(1);
// Enable room selection
map.setSelectable(true);
// Set callback for selection events
map.setSelectionListener(function(roomId) {
if (roomId === -1) {
console.log("Nothing selected");
} else {
console.log("Selected room ID:", roomId);
// Handle room selection (show info panel, etc.)
}
});
// Programmatically select a room by ID
map.selectById(12345);
// Get currently selected room ID
var selectedId = map.getSelectedId();
});
```
--------------------------------
### Display Floors
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Controls which floors are visible. `showFloor()` displays a specific floor, while `showAllFloors()` stacks all floors in 3D mode. Also includes methods to retrieve floor information.
```javascript
var map = new IndoorMap({ mapDiv: "indoor3d", dim: "3d" });
map.load('data/mallMapData.json', function() {
// Show a specific floor by ID
// Floor IDs: positive for upper floors (F1=1, F2=2), negative for basement (B1=-1)
map.showFloor(1); // Show floor F1
// Show all floors stacked (3D mode only)
map.showAllFloors();
// Get current floor information
var currentFloorId = map.mall.getCurFloorId(); // Returns 0 when showing all floors
var currentFloor = map.mall.getCurFloor();
var floor2 = map.mall.getFloor(2);
var floorByName = map.mall.getFloorByName("F2");
});
```
--------------------------------
### Room Selection
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Methods to enable, handle, and programmatically trigger room selection events.
```APIDOC
## map.setSelectable(boolean)
### Description
Enables or disables room selection functionality.
## map.setSelectionListener(callback)
### Description
Sets a callback function to be triggered when a room is selected. The callback receives the roomId as an argument.
## map.selectById(roomId)
### Description
Programmatically selects a room by its ID.
```
--------------------------------
### Map Interaction and UI
Source: https://github.com/wolfwind521/indoor3d/blob/master/README.md
Methods for configuring map interactivity and retrieving UI elements.
```APIDOC
## .setSelectable(selectable)
### Description
Specifies whether rooms are selectable.
### Parameters
- **selectable** (boolean) - Required - True to enable selection.
## .showLabels(showLabels)
### Description
Specifies whether to show map labels (icons and text).
### Parameters
- **showLabels** (boolean) - Required - True to show labels.
## .getUI()
### Description
Returns a
element containing floor IDs for navigation. Must be called after the map is loaded.
```
--------------------------------
### Toggle Map Labels and Public Points
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Use these methods to control the visibility of room names and facility icons. Methods support chaining for efficient configuration.
```javascript
var map = new IndoorMap({ mapDiv: "indoor3d" });
map.load('data/mallMapData.json', function() {
map.showFloor(1);
// Show/hide room name labels
map.showAreaNames(true); // Show labels
map.showAreaNames(false); // Hide labels
// Show/hide public point icons (toilets, ATMs, escalators, etc.)
map.showPubPoints(true); // Show icons
map.showPubPoints(false); // Hide icons
// Chain multiple settings
map.showAreaNames(true).showPubPoints(true).setSelectable(true);
});
```
--------------------------------
### Map Data Loading and Styling
Source: https://github.com/wolfwind521/indoor3d/blob/master/README.md
Loading map data and applying styles or UI components via callback or chaining.
```javascript
indoorMap.load('data/testMapData.json', function(){
map.setTheme(myTheme).showAllFloors().showAreaNames(true).setSelectable(true);
var ul = IndoorMap.getUI(indoorMap);
document.body.appendChild(ul);
});
```
```javascript
map.setTheme(myTheme);
map.showAllFloors();
map.showAreaNames(true);
map.setSelectable(true);
```
```javascript
map.setTheme(myTheme).showAllFloors().showAreaNames(true).setSelectable(true);
```
--------------------------------
### Shop Selection Management
Source: https://github.com/wolfwind521/indoor3d/blob/master/README.md
Methods for handling shop selection events and state.
```APIDOC
## .setSelectionListener(callback)
### Description
Sets a callback function triggered when a shop is selected. The shop ID is passed as a parameter (-1 if nothing is selected).
## .getSelectedId()
### Description
Returns the ID of the currently selected shop.
## .selectById(id)
### Description
Selects a shop by its ID.
### Parameters
- **id** (number) - Required - The shop ID.
```
--------------------------------
### Apply Custom Map Themes
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Define a theme object to customize colors, opacity, fonts, and icon paths. Pass the object to the setTheme method after the map data has loaded.
```javascript
var customTheme = {
name: "myTheme",
background: "#FFFFFF",
building: {
color: "#000000",
opacity: 0.1,
transparent: true,
depthTest: false
},
floor: {
color: "#E0E0E0",
opacity: 1,
transparent: false
},
selected: "#ffff55", // Highlight color for selected rooms
// Room colors based on type and category
room: function(type, category) {
if (category === 101) { // Food
return { color: "#1f77b4", opacity: 0.7, transparent: true };
}
if (category === 102) { // Retail
return { color: "#aec7e8", opacity: 0.7, transparent: true };
}
// Default style
return { color: "#c49c94", opacity: 0.7, transparent: true };
},
strokeStyle: {
color: "#666666",
opacity: 0.5,
transparent: true,
linewidth: 1
},
fontStyle: {
color: "#333333",
fontsize: 13,
fontface: "Helvetica, Arial, sans-serif",
textAlign: "center",
textBaseline: "middle"
},
pubPointImg: {
"11001": "img/toilet.png",
"11002": "img/ATM.png",
"21001": "img/stair.png",
"21002": "img/escalator.png",
"21003": "img/lift.png",
"22006": "img/entry.png"
}
};
var map = new IndoorMap({ mapDiv: "indoor3d" });
map.load('data/mallMapData.json', function() {
map.setTheme(customTheme);
map.showFloor(1);
});
```
--------------------------------
### Zoom and Camera Controls
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Manages map navigation with zoom functions and camera view presets. Use `setDefaultView()`, `setTopView()`, and `adjustCamera()` for different perspectives.
```javascript
var map = new IndoorMap({ mapDiv: "indoor3d", dim: "3d" });
map.load('data/mallMapData.json', function() {
map.showFloor(1);
// Zoom in (optional scale factor, default varies)
map.zoomIn(1.2);
// Zoom out
map.zoomOut(0.8);
// Reset to default perspective view
map.setDefaultView();
// Set top-down view (3D mode only)
map.setTopView();
// Adjust camera to fit current floor
map.adjustCamera();
});
```
--------------------------------
### Floor Management
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Methods to display specific floors or all floors simultaneously.
```APIDOC
## map.showFloor(id)
### Description
Displays a specific floor by its ID. Positive IDs for upper floors, negative for basement.
## map.showAllFloors()
### Description
Displays all floors in a stacked 3D view (3D mode only).
```
--------------------------------
### Floor Management
Source: https://github.com/wolfwind521/indoor3d/blob/master/README.md
Methods for controlling floor visibility and retrieving floor information.
```APIDOC
## .showFloor(id)
### Description
Shows a specific floor by ID. Does not handle labels.
### Parameters
- **id** (number) - Required - The floor ID.
## .showAllFloors()
### Description
Shows all floors simultaneously. Does not handle labels.
## .getCurFloorId()
### Description
Returns the current floor ID. -1 represents B1, 1 represents F1, and 0 represents all floors.
## .getFloor(id)
### Description
Returns the THREE.Object3D representation of a floor.
### Parameters
- **id** (number) - Required - The floor ID.
## .getCurFloor()
### Description
Returns the THREE.Object3D representation of the current floor.
```
--------------------------------
### Camera and View Controls
Source: https://github.com/wolfwind521/indoor3d/blob/master/README.md
Methods to manipulate the camera view and zoom levels.
```APIDOC
## .setDefaultView()
### Description
Resets the camera to the default perspective (3D) or top view (2D).
## .setTopView()
### Description
Sets the camera to top view (valid only in 3D map).
## .zoomIn(zoomScale)
### Description
Zooms in the map view.
### Parameters
- **zoomScale** (number) - Optional - The scale factor for zooming.
## .zoomOut(zoomScale)
### Description
Zooms out the map view.
### Parameters
- **zoomScale** (number) - Optional - The scale factor for zooming.
## .adjustCamera
### Description
Resets the camera to default settings, typically used when switching floors.
```
--------------------------------
### Map Data Loading
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Methods for loading map data from external JSON files or parsing existing JSON objects.
```APIDOC
## map.load(url, callback)
### Description
Fetches map data from a JSON file and initializes the map. The callback function is executed after the data is fully loaded.
## map.parse(data)
### Description
Allows passing pre-loaded JSON data directly to the map instance instead of loading from a file.
```
--------------------------------
### Parse JSON Map Data Directly
Source: https://context7.com/wolfwind521/indoor3d/llms.txt
Parses pre-loaded JSON data directly into the map instance. Useful when data is fetched or generated client-side.
```javascript
var map = new IndoorMap({ mapDiv: "indoor3d" });
// Assuming mapData is already loaded JSON
var mapData = {
data: {
building: { /* building outline and properties */ },
Floors: [
{
_id: 1,
Name: "F1",
Outline: [[[/* polygon points */]]],
FuncAreas: [/* rooms/shops */],
PubPoint: [/* public facilities */]
}
]
}
};
map.parse(mapData);
map.showFloor(1).showAreaNames(true);
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.