Skip to Content
APIMapInterface: MapVXMap

Interface: MapVXMap

Routes

fitRouteByPlace()

MVXRoute

Adjusts the map view to show only the steps within a specific place/building. This method filters route steps that belong to the specified place (either starting or ending inside it) and fits the map bounds to display those steps. This is particularly useful for indoor navigation where routes may cross multiple buildings or floors, allowing the map to focus on the current location.

Parameters

route

MVXRoute

The complete route containing all steps

placeId

string

The ID of the place/building to filter steps by

options?

FitOptions

Optional fit options including padding, maxZoom, etc. If not provided, uses default padding values.

Returns

void

Example

string

Methods

addBorderToPlaces()

FitOptions

Add a border to the specific places on the map.

It only function with the internal ids from MapVX and not the clients ids.

If you only have a client id and need to use this function, you can obtain the corresponding mapvx id from the place data using the SDK function getPlaceDetail for example.

The color and width optional arguments only function when both are sent. You should use them with caution, because all future call will have that as the base style.

Parameters

placeIds

string[]

An array of strings representing the MapVX IDs of the places that need to have a border on the map.

color?

string

The color to use for the border instead of the current color defined in the style.

width?

number

The width for the borders instead of the current color defined in the style.

Returns

void


addMarker()

void

Adding a marker to the map and to the list of current marker references.

Parameters

marker

MarkerConfig

specifications for marker creation.

Returns

string

returns the added marker id.


addRoute()

getPlaceDetail

Adds a new route to the map or replaces the old one.

Parameters

config

GetRouteConfiguration

drawConfig?

DrawRouteConfiguration

Returns

Promise<MVXRoute>

The route added to the map.


addStepAnimation()

color

Add a step animation to the map.

Parameters

routeConfig

Parameters to get a route or the route object

MVXRoute | GetRouteConfiguration

drawConfig?

AnimationDrawingConfig

animationConfig?

AnimationConfig

Returns

Promise<MVXRoute>


addStepAnimationV2()

width

Add a step animation to the map. Use a new endpoint for the route data.

Parameters

routeConfig

Parameters to get a route or the route object

MVXRoute | GetRouteConfiguration

drawConfig?

AnimationDrawingConfig

animationConfig?

AnimationConfig

Returns

Promise<MVXRoute>


addUserLocationTracking()

string

Geolocate the user and track their current location on the current map

Parameters

enableHighAccuracy?

boolean

if true, it’ll get try to receive the best possible location results

geoLocation?

Geolocation

the geolocation object to use for tracking the user’s location. If not provided, it’ll use the default navigator.geolocation object.

icon?

HTMLElement

optional custom HTML element to use as the user location marker icon

Returns

void


centerOnCurrentStepAnimation()

string

Center the map on the current marker position for animation based on steps

Parameters

routeId?

string

Optional ID of the specific route. If not provided, uses the last added route.

Returns

void


clearBorderedPlaces()

number

Clear the borders added with addBorderToPlaces.

Returns

void


clearColoredPlaces()

void

Clear the colored places on the map. This clear the places colored with setPlacesAsSelected.

Returns

void


clearTileCache()

MarkerConfig

Clears the tile cache, forcing tiles to be re-fetched on next request. This clears both the in-memory MapLibre cache and triggers a repaint.

Returns

void

Remarks

Useful when:

  • Style has been updated on the server
  • You want to free up memory
  • Tiles appear corrupted or outdated

destroyMap()

string

Destroy the current map

Returns

void


fitCoordinates()

GetRouteConfiguration

Change the camera of the map to contain the visible area within an specific list of LatLng. If coordinates is empty, it doesn’t do anything. If it’s only one coordinate, the map center will be at that point.

The fit operation preserves the current bearing and pitch unless explicitly overridden in options.

Parameters

coordinates

LatLng[]

List of LatLng coordinates in where the map will fit

options?

FitOptions

Support for various options for the fit, including:

  • bearing: Camera bearing (rotation) in degrees. Defaults to current bearing.
  • pitch: Camera pitch (tilt) in degrees. Defaults to current pitch.
  • onComplete: Callback executed when the fit animation completes.

Returns

void

Example

DrawRouteConfiguration


getActiveRouteIds()

Promise

Get the IDs of all active routes on the map.

Returns

string[]

Array of route IDs.


getBearing()

MVXRoute

Returns the map’s current bearing. The bearing is the compass direction that is “up”; for example, a bearing of 90° orients the map so that east is up.

Returns

number

The map’s current bearing.


getContainer()

MVXRoute

Returns the map’s containing HTML element.

Returns

HTMLElement

The map’s container.


getCurrentFloor()

GetRouteConfiguration

Obtain the id of the current floor. If not set the parent place, return a empty string.

Returns

string


getZoomLevel()

AnimationDrawingConfig

Obtain the current zoom level of the map.

Returns

number


hideMarker()

AnimationConfig

Hides the marker with the specified ID. This function will make the marker invisible on the map.

Parameters

markerId

string

The ID of the marker to hide.

Returns

void


isInsideBounds()

Promise

Check if given position is inside map bounds or not

Parameters

point

LatLng

position to check

Returns

boolean

True if inside bounds or if the map doesn’t have max bounds set, False otherwise


nextStepAnimation()

MVXRoute

Animate the current step and leave the map ready for the next step animation.

Parameters

routeId?

string

Optional ID of the specific route. If not provided, uses the last added route.

Returns

void


pauseAnimateRoute()

MVXRoute

Pause of the route animation on the map.

Parameters

routeId?

string

Optional ID of the specific route to pause. If not provided, pauses the last added route.

Returns

void

Throws

A error if not exist on the map a route added by startAnimateRoute.


previousStepAnimation()

GetRouteConfiguration

Leave the map ready to animate the previous step.

Parameters

routeId?

string

Optional ID of the specific route. If not provided, uses the last added route.

Returns

void


removeAllMarkers()

AnimationDrawingConfig

Removes all markers from the map. This function will clear all markers currently displayed on the map.

Returns

void


removeAllRoutes()

AnimationConfig

Remove all routes from the map.

Returns

void


removeMarker()

Promise

Removes from the current map the marker that corresponds to the id provided

Parameters

markerId

string

specifications for marker creation.

Returns

void


removeParentPlace()

MVXRoute

Removes parent place property for current map

Returns

void


removeRoute()

boolean

Removes a route from the map. When called without arguments, removes the most recently added route (backward compatible).

Parameters

routeId?

string

Optional ID of the specific route to remove.

Returns

void

Remarks

Remove the routes added with addRoute or startAnimateRoute.


removeRouteById()

true

Remove a specific route from the map by its ID.

Parameters

routeId

string

The ID of the route to remove.

Returns

void


removeUserLocationTracking()

Geolocation

Remove user location tracking from the map

Returns

void


restartAnimateRoute()

HTMLElement

Restart the animation of the route.

Parameters

routeId?

string

Optional ID of the specific route to restart. If not provided, restarts the last added route.

Returns

void

Throws

A error if not exist on the map a route added by startAnimateRoute.


resumeAnimateRoute()

void

Resume of the route animation on the map.

Parameters

routeId?

string

Optional ID of the specific route to resume. If not provided, resumes the last added route.

Returns

void

Throws

A error if not exist on the map a route added by startAnimateRoute.


setLang()

string

function to change the lang of requests

Parameters

lang

string

request response language

Returns

void


setMaxBounds()

void

Limits the movement of the map to a bounding box calculated with the coordinate array If the coordinates are less than 2, then the function does nothing.

Parameters

coordinates

LatLng[]

List of LatLng coordinates in which the map will be limited, to these coordinates is added one kilometer of padding.

options?

BoundsOptions

Optional settings including onComplete callback

Returns

void

Example

void


setMaxZoom()

void

Adjusts the upper zoom limit

Parameters

zoomLvl

number

The maximum zoom level

options?

ZoomOptions

Optional settings including onComplete callback

Returns

void

Example

void


setMinZoom()

void

Adjusts the lower zoom limit

Parameters

zoomLvl

number

The minimum zoom level

options?

ZoomOptions

Optional settings including onComplete callback

Returns

void

Example

LatLng


setParentPlace()

FitOptions

Sets selected place as new parent place for loaded map and, if desired, loads new style

Parameters

place

MVXPlace

The new parent place

updateStyle

boolean

Defines whether the new parent place’s style must be set

onStyleReady?

() => void

A callback function to be executed when the style loading is completed

Returns

void


setPlacesAsSelected()

bearing

Colors specific places on the map based on provided place IDs.

It only function with the internal ids from MapVX and not the clients ids.

The function sets map filters to highlight given places on the displayed floor. Places previously marked as selected will lose such effect unless their id is provided in the latest call of the function. Therefore, if input array is empty, no place will be marked as selected in the map after function call.

You should use the color with caution because all future call will have that as the base color.

If you only have a client id and need to use this function, you can obtain the corresponding mapvx id from the place data using the SDK function getPlaceDetail for example.

Parameters

placeIds

string[]

An array of strings representing the MapVX IDs of the places that need to be colored on the map.

color?

string

The color to use for the polygons instead of the current color defined in the style.

Returns

void


showMarker()

pitch

Shows the marker with the specified ID. This function will make the marker visible on the map.

Parameters

markerId

string

The ID of the marker to show.

Returns

void


startAnimateRoute()

onComplete

Start of the route animation on the map

Parameters

routeConfig

Parameters to get a route or the route object.

MVXRoute | GetRouteConfiguration

drawConfig?

AnimationDrawingConfig

The configuration of how to draw the route on the map.

animationConfig?

AnimationConfig

Parameters for the specified animation.

Returns

Promise<MVXRoute>

The route that will be animated.


startAnimateRouteV2()

void

Start of the route animation on the map. Use a new endpoint for the route data.

Parameters

routeConfig

Parameters to get a route or the route object.

MVXRoute | GetRouteConfiguration

drawConfig?

AnimationDrawingConfig

The configuration of how to draw the route on the map.

animationConfig?

AnimationConfig

Parameters for the specified animation.

Returns

Promise<MVXRoute>

The route that will be animated.


startClickListener()

string

Function to activate the listening to the clicks of places on the map

Parameters

callback

(arg) => void

The function that receive the id of the clicked place.

Returns

void


stopAnimateRoute()

number

Complete stop of the route animation on the map

Returns

void

Deprecated

Not yet implemented.


stopClickListener()

HTMLElement

Function to deactivate the listening to the clicks of places on the map

Returns

void


updateCamera()

string

Update the camera position on the map

Parameters

newCamera

MapCamera & CameraAnimation

Options for camera update.

callback?

() => void

Function to execute after the camera updates

Returns

void


updateFloor()

number

Updates the floor shown on the map and the reference to the current floor.

Parameters

floorId

string

floor identifier.

options?

FloorUpdateOptions

Optional settings including onComplete callback

Returns

void

Example

string


updateMarker()

void

update a marker to the map and to the list of current marker references.

Parameters

marker

MarkerConfig

specifications for marker creation.

Returns

string

returns the added marker id.


updateMarkerPosition()

LatLng

Update the position of a marker on the map.

Parameters

markerId

string

The id of the marker.

newPosition

LatLng

The new position of the marker.

Returns

void


updateParentPlaceAndFloor()

boolean

Update the current parent place and floor displayed on the map.

Parameters

parentPlaceId

string

The id of the parent place to show.

floorId?

string

The id of the floor to show.

options?

FloorUpdateOptions

Optional settings including onComplete callback

Returns

void

Example

string


updateRouteProgress()

void

Update the visual progress of a route based on an external user position. Splits the route into behind (already traveled) and ahead (remaining) portions at the point on the route closest to the given position.

Parameters

routeId

string

The ID of the route to update.

position

LatLng

The current user position (will be projected onto the route).

behindStyle?

RouteStyle

Optional style for the behind (traveled) portion. Defaults to gray solid.

Returns

void

Last updated on