Controls for the map's camera.
Provides methods for camera positioning, zooming, panning, and view control.
Controls for the map's 3D images.
Manages image overlays and custom image elements on the map.
Controls for the map's labels.
Manages text overlays, tooltips, and label visibility on the map.
Controls for the map's markers.
Manages point-based visual elements like pins, icons, and custom markers.
Controls for the map's models.
Manages 3D model rendering and positioning on the map.
Controls for the map's navigation.
Controls for the outdoor map.
Manages outdoor map integration and outdoor tile rendering.
Controls for the map's paths.
Manages route visualization, navigation paths, and custom path rendering.
Controls custom GeoJSON geometry on the map.
Allows adding custom geometric shapes and overlays to the map.
Controls for the indoor map's style.
ExperimentalText3DControls for the map's 3D texts.
Provides 3D text rendering capabilities for enhanced visual effects.
The container element of the map.
Gets the current (FloorStack).
The current FloorStack, or undefined if no floor stack is set.
The options passed in to the show3dMap method during initialization.
The group which manages all tweens created with tween or animateState.
ExperimentalThis is an experimental feature that may undergo significant changes, including breaking changes, renaming, or complete removal in future versions. Do not rely on this API in production environments.
Automatically creates labels, markers, and updates state of map elements provided with default settings.
OptionalmapElements: MapDataElements[]A custom array of map elements to automatically create labels, markers, and update state of. If not provided, all map elements will be used.
An object containing auto-created labels and markers.
Gets the rendered state of a map element.
Retrieves runtime rendering state that changes frequently, such as text visibility for labels.
The map element to get the rendered state for.
An object containing the requested rendered state keys, or undefined if not found.
Animate the state of a given target on the map from the current state to a new state. Only numeric properties and colors can be animated.
Use updateState() for immediate updates.
The following table maps targets to their available states:
| Target | State Type | Description |
|---|---|---|
| Door | TDoorsUpdateState | Open/closed state, color |
| Floor | TFloorUpdateState | Color, opacity, visibility |
| Label | TLabelUpdateState | Text, color, visibility |
| Marker | TMarkerUpdateState | Color, size, icon |
| Model | TModelUpdateState | Scale, rotation, visibility |
| Path | TPathUpdateState | Color, width, visibility |
| Shape | TShapeUpdateState | Color, opacity, geometry |
| Space | TGeometryUpdateState | Color, opacity, visibility |
| Text3DView | TText3DUpdateState | Text, color, height |
| DOORS | TDoorsUpdateState | Global door settings |
| WALLS | TWallsUpdateState | Global wall settings |
The map element to animate.
The target state to animate to.
Optionaloptions: {Animation configuration options.
Optionalduration?: numberThe duration of the animation in milliseconds (default: 1000).
Optionaleasing?: "ease-in" | "ease-out" | "ease-in-out" | "linear"The easing function to use for the animation.
A cancellable promise that resolves when the animation completes.
mapView.animateState(label, {
appearance: {
textSize: state.appearance.textSize! + 1,
textColor: state.appearance.textColor! === '#000000' ? 'purple' : '#000000',
},
});
to interactive when the animation completes.
mapView.on('click', ({ spaces }) => {
if (!spaces) return;
spaces.forEach(space => {
const state = mapView.getState(space)!;
mapView.updateState(space, {
interactive: false,
});
currentAnimation = mapView.animateState(space, {
height: state.height + 1,
color: state.color === 'rgb(255, 0, 0)' ? 'blue' : 'rgb(255, 0, 0)',
});
currentAnimation.finally(() => {
mapView.updateState(space, {
interactive: true,
});
});
});
});
Clears all added elements from the map.
Creates a Coordinate on the map.
The latitude of the coordinate.
The longitude of the coordinate.
Optionalfloor: FloorOptional floor information if applicable.
The created Coordinate object.
Creates a Coordinate on the map using a params object.
An object containing the coordinate parameters.
OptionalfloorId?: stringOptional ID of the Floor this Coordinate is on.
The latitude of the Coordinate.
The longitude of the Coordinate.
OptionalverticalOffset?: numberOptional vertical offset from the Floor in meters.
The created Coordinate object.
// Create a coordinate at the CN Tower using params object.
const coord = map.createCoordinate({
latitude: 43.642567,
longitude: -79.387054
});
// Alternatively, you can directly use the Coordinate constructor:
import { Coordinate } from '@mappedin/mappedin-js';
const coord = new Coordinate({
latitude: 43.642567,
longitude: -79.387054,
floorId: 'floor1',
verticalOffset: 10
});
ExperimentalCreate a Coordinate from an X and Y position measured in pixels from the top left corner of the map canvas.
Optionalfloor: FloorDestroys the MapView.
ExperimentalEnable debug interface. Learn more about the debug interface in the Debug Mode Guide.
Calculates (Directions) from one navigable point (TNavigationTarget) to another on the map.
Provides turn-by-turn navigation instructions and route visualization. This method delegates to the MapData instance.
The starting location(s).
The destination location(s).
Optionaloptions: TGetDirectionsOptionsOptional configuration for the directions calculation.
A Promise resolving to a Directions object containing the route, or undefined if no route is found.
In enterprise mode, path smoothing is disabled by default. Use the smoothing option to explicitly enable it if needed.
const space1 = mapData.getById('space', 'space-123');
const space2 = mapData.getById('space', 'space-456');
if (space1 && space2) {
const directions = await mapView.getDirections(space1, space2);
if (directions) {
// Show the route on the map
mapView.Paths.show(directions);
console.log(`Distance: ${directions.distance}m`);
}
}
Calculates directions (Directions) from one navigable point (TNavigationTarget) to multiple destination points on the map.
Provides routes from a single starting point to multiple destinations. This method delegates to the MapData instance.
The starting location.
An array of destination locations or arrays of destinations.
Optionaloptions: TGetDirectionsOptionsOptional configuration for the directions calculation.
A Promise resolving to an array of Directions objects, one for each destination.
In enterprise mode, path smoothing is disabled by default. Use the smoothing option to explicitly enable it if needed.
const start = mapData.getById('space', 'entrance');
const destinations = [
mapData.getById('space', 'store-1'),
mapData.getById('space', 'store-2'),
mapData.getById('space', 'restaurant')
].filter(Boolean);
const allDirections = await mapView.getDirectionsMultiDestination(start, destinations);
allDirections.forEach((directions, index) => {
console.log(`Route ${index + 1}: ${directions.distance}m`);
});
Calculates the walking distance between two navigable points (TNavigationTarget) on the map.
Returns the walking distance between two points. This method delegates to the MapData instance.
The starting location.
The destination location.
The distance in meters.
Get global state of the MapView
Gets the map elements that are currently in view.
The type of map element to get.
Optionaloptions: Partial<{ fullyContains: boolean; screenOffsets: Partial<InsetPadding> }>Optional configuration for the in view check.
An array of map elements that are currently in view.
Gets the current map data associated with this view.
The current MapData instance, or undefined if no map is loaded.
ExperimentalGet the X and Y of a Coordinate measured from the top left corner of the map canvas.
Gets the current state of a map element.
Retrieves the current visual properties and state of a map element.
The map element to get the state for.
The current state of the element.
Determines if a given target is within the viewport.
This method checks if the specified target, such as a Space, MapObject, Label, Marker, or string identifier,
is currently within the visible area of the map viewport. Note that this method returns true even if the
target is not visible (e.g., its visibility is set to false).
A boolean indicating whether the target is within the viewport.
Unsubscribe a function previously subscribed with on
An event name to which the provided function was previously subscribed.
A function that was previously passed to on. The function must have the same reference as the function that was subscribed.
Subscribe a function to an event.
An event name which, when fired, will call the provided function.
A callback that gets called when the corresponding event is fired. The callback will get passed an argument with a type that's one of event payloads.
Preload floor geometry and outlines for the map at runtime. Can be used when anticipating a large number of floors will be visible at once to keep the map responsive.
The floors to preload.
Sets the current floor of the map.
Changes the visible floor and updates the camera to focus on the new floor.
The floor to set, either as a Floor object or floor ID string.
Optionaloptions: TSetFloorOptionsOptional configuration for the floor change.
A promise that resolves when the floor change is complete.
Sets the current (FloorStack) of the map.
Changes to a specific floor stack, which may contain multiple floors for complex buildings.
The floor stack to set, either as a (FloorStack) object or ID string.
Optionaloptions: TSetFloorOptionsOptional configuration for the floor stack change defined in (TSetFloorOptions).
A promise that resolves when the floor stack change is complete.
ExperimentalTakes a screenshot of the current scene and returns it as a data URL.
NOTE: This only captures the 3D scene, and optionally the outdoor context, not the UI elements like labels, markers, etc. Also, this does not cause the screenshot to be saved to the user's device, it only returns the data.
Optionaloptions: TTakeScreenshotOptionsOptions for taking a screenshot.
A Promise that resolves with the screenshot as a base64-encoded data URL string
Create a tween object that will be updated on every render frame. See https://tweenjs.github.io/tween.js/docs/user_guide.html for more information.
When creating a large number of tween objects, it may be important to call removeTween to prevent memory leaks.
The data to be tweened.
The tween object.
Update global state of the MapView
OptionalbackgroundAlpha?: numberThe alpha value of the background, between 0 and 1.
OptionalbackgroundColor?: stringThe color of the background, in hex format(#000000).
Optionalenvironment?: EnvMapOptionsenvironment map for reflections.
Optionalgeometry?: { hoverColor?: string }OptionalhoverColor?: stringhover color of the geometries
Optionaltext3d?: { hoverColor?: string }OptionalhoverColor?: stringhover color of the text3d
Updates the state of a map element immediately.
This method provides direct control over the visual properties of map elements. Use animateState() for smooth transitions.
The following table maps targets to their available states:
| Target | State Type | Description |
|---|---|---|
| Door | TDoorsUpdateState | Open/closed state, color |
| Floor | TFloorUpdateState | Color, opacity, visibility |
| Label | TLabelUpdateState | Text, color, visibility |
| Marker | TMarkerUpdateState | Color, size, icon |
| Model | TModelUpdateState | Scale, rotation, visibility |
| Path | TPathUpdateState | Color, width, visibility |
| Shape | TShapeUpdateState | Color, opacity, geometry |
| Space | TGeometryUpdateState | Color, opacity, visibility |
| Text3DView | TText3DUpdateState | Text, color, height |
| DOORS | TDoorsUpdateState | Global door settings |
| WALLS | TWallsUpdateState | Global wall settings |
The map element to update.
The new state to apply.
MapView in Mappedin JS
MapView is the main rendering and interaction class for Mappedin maps. It provides comprehensive controls for manipulating map elements, camera, styling, and user interactions.
Features
Example Usage
Core Components
State Management
updateState(): Immediate state changesanimateState(): Smooth animated transitionsgetState(): Retrieve current element statesupdateGlobalState(): Apply global styling changesEvent Handling
More Information
The MapView class is the main class for rendering and interacting with the map.
It provides a set of controls for manipulating the map's elements and state.
For help getting started, refer to the Getting Started Guide.