Interface: MapVXSDK
Methods
cleanRoutesCache()
cleanRoutesCache(): void;Delete cache for normal and accessible routes if exist
Returns
void
createMap()
createMap(container, mapConfig): MapVXMap;Creates a map within a specified HTML element container using the provided map configuration.
Parameters
container
HTMLElement
The html element where the map will be in your page.
mapConfig
The configuration for the map.
Returns
The created MapVXMap object.
Throws
Will throw an error if the map creation fails.
getAnyPlaceDetail()
getAnyPlaceDetail(place, authToken): Promise<MVXPlace>;Get the information from a place. Might be a place that is not necessarily allowed by the ApiKey.
Accepts either a plain place id (string) or a PlaceQuery
object. Use the object form to disambiguate an internal alias reused across buildings by providing
buildingId and, optionally, floorId/level.
Parameters
place
The id of the place, or a PlaceQuery with disambiguation.
string | PlaceQuery
authToken
string
The auth token of the user.
Returns
Promise<MVXPlace>
Throws
Will throw an error if fail to get the detail of the place.
getAnySubPlaces()
getAnySubPlaces(parentPlaceId, authToken): Promise<MVXPlace[]>;Get the sub-places from a parent place. Might include sub-places not necessarily allowed by the ApiKey.
Parameters
parentPlaceId
string
The id of the parent place.
authToken
string
The auth token of the user.
Returns
Promise<MVXPlace[]>
A promise with the list of sub-places.
Throws
Will throw an error if fail to get the sub-places.
getAvailablePlaces()
getAvailablePlaces(): Promise<MVXPlace[]>;Get the places associated to the token added on the class constructor.
This method also returns all places associated with the allowed institutions.
Also this return child_places as a list of string.
Returns
Promise<MVXPlace[]>
A list of the places associated to the token.
Throws
Will throw an error if fail to get the parent places.
getCachedPlaces()
getCachedPlaces(ids): MVXPlace[];Get the cached information of the places.
If a id is not cached, it will be ignored.
Parameters
ids
string[]
The identification of the places
Returns
MVXPlace[]
getCacheTimestamp()
getCacheTimestamp(parentPlaceId): Promise<number>;Returns the timestamp of the last cache update for the specified parent place.
Parameters
parentPlaceId
string
Id of parent place whose cache timestamp is requested
Returns
Promise<number>
getCategories()
getCategories(placeId?): Promise<Category[]>;Obtain categories of a place
Parameters
placeId?
string
parent place identifier
Returns
Promise<Category[]>
getConfiguration()
getConfiguration(placeId?, product?): Promise<Configuration>;Obtain initial configuration of a parent place map
Parameters
placeId?
string
parent place identifier
product?
MapVxProduct
product type caller of the configuration, currently supports “directory”, “totems”, and “demo”
Returns
Promise<Configuration>
getCssCustomization()
getCssCustomization(type): Promise<CssCustomization>;Get the CSS customization associated with the api key for the different products. For now is available only for the type ‘totems’.
Parameters
type
string
The type of product for which customization is required (ex. ‘totems’).
Returns
Promise<CssCustomization>
A json with the css customization.
getInstitutions()
getInstitutions(): Promise<Institution[]>;Get information from all institutions of the apiKey.
The type of the property child_places of the returned values is a list of string.
Returns
Promise<Institution[]>
The information from all institutions of the apiKey.
getLiveRoute()
getLiveRoute(routeConfig): Promise<MVXRoute>;Get a route from the live routing endpoint (/sdk/liveroute). Parallel to getRoute;
the live service is always fetched fresh (never served from cache).
Parameters
routeConfig
The configuration to describe the requested route.
Returns
Promise<MVXRoute>
The information of the route.
getPlaceDetail()
getPlaceDetail(place): Promise<MVXPlace>;Get the information from a place.
Accepts either a plain place id (string) or a PlaceQuery
object. Use the object form to disambiguate an internal alias that is reused across several
buildings (e.g. the same store alias present in different shopping malls) by providing buildingId
and, optionally, floorId/level.
Parameters
place
The id of the place, or a PlaceQuery with disambiguation.
string | PlaceQuery
Returns
Promise<MVXPlace>
Throws
Will throw an error if fail to get the detail of the place.
Example
// Backward compatible: lookup by id/alias only.
await sdk.getPlaceDetail("place-123")
// Disambiguate an alias shared across malls.
await sdk.getPlaceDetail({
id: "store-204",
buildingId: "mall-santiago",
floorId: "level-2",
})getPlacesByCategory()
getPlacesByCategory(category): Promise<MVXPlace[]>;Get a list of places from a determined category.
Parameters
category
string
The category for which you want to obtain its places.
Returns
Promise<MVXPlace[]>
A list with the places from that category.
Deprecated
Not yet implemented.
getPlacesByInput()
getPlacesByInput(
input,
institutionId,
parentPlaceId?,
otherParentPlacesIds?,
origin?,
lat?,
lng?,
floor?): Promise<MVXPlace[]>;Get a list of places that match a input. The orden on the list is from high to low match.
Note: The parameters parentPlaceId and otherParentPlacesIds will be unified on the next major
version.
Parameters
input
string
The user input
institutionId
string
The identifier of the institution to search within
parentPlaceId?
string
(Optional) A parent place identifier to filter the results.
otherParentPlacesIds?
string[]
(Optional) An array of parent place ids to filter the results.
origin?
string
(Optional) The ID of a totem or a place origin from directories. Used to return search results based on distance from the origin.
lat?
string
(Optional) Latitude as a string for location-based search.
lng?
string
(Optional) Longitude as a string for location-based search.
floor?
string
(Optional) Floor ID as a string for location-based search.
Returns
Promise<MVXPlace[]>
A list with the places that match the input.
getPlacesFromInstitution()
getPlacesFromInstitution(institutionId, authToken): Promise<MVXPlace[]>;Get the list of places from a specific institution. Might include places not necessarily allowed by the ApiKey.
Parameters
institutionId
string
The id of the institution.
authToken
string
The auth token of the user.
Returns
Promise<MVXPlace[]>
A promise with the list of places from the institution.
Throws
Will throw an error if fail to get the places from the institution.
getRoute()
getRoute(routeConfig): Promise<MVXRoute>;Get a route.
Parameters
routeConfig
The configuration to describe the requested route.
Returns
Promise<MVXRoute>
The information of the route.
getRouteV2()
getRouteV2(routeConfig): Promise<MVXRoute>;Get a route. Use a new endpoint for the route data.
Parameters
routeConfig
The configuration to describe the requested route.
Returns
Promise<MVXRoute>
The information of the route.
getSubPlaces()
getSubPlaces(parentPlaceId): Promise<MVXPlace[]>;Get the sub-places from a parent place.
Parameters
parentPlaceId
string
The place identifier from which will be obtained is sub-places.
Returns
Promise<MVXPlace[]>
A promise with a list of sub-places.
getTransport()
getTransport(stopId): Promise<MVXTransport>;Obtains the data of a particular transport according to the identifier
Parameters
stopId
string
Returns
Promise<MVXTransport>
A object MVXTransport with the information of the stop
Throws
Will throw an error if fail to get the transport information
getUserLocation()
getUserLocation(): Promise<GeolocationPosition>;Get location of current user with latitude and longitude info
Returns
Promise<GeolocationPosition>
Single location object with LatLng of current user
loadRoutesForOriginCache()
loadRoutesForOriginCache(
parentPlaceId,
fromPlaceId,
announceFormat,
unitSystem,
mode): void;Retrieves information of routes from an specific place to every other subplace of it’s own parent place. Then populates a cache which will be consulted -and accessed if possible- each time a route is requested from the selected origin place.
Parameters
parentPlaceId
string
Parent place of origin and destination places.
fromPlaceId
string
Origin place of requested routes.
announceFormat
The desired format for the route instructions announcement.
unitSystem
The unit system used for the route distance measurements.
mode
The transportation mode to be used in the routes.
Returns
void
notifyHealth()
notifyHealth(
healthPingId,
placeId,
totemId,
status): Promise<HealthResponse>;Notify to the server the current status of the totem,
Parameters
healthPingId
string
The id for the health ping.
placeId
string
The id of the place.
totemId
string
The id of the totem
status
boolean
The status of the totem.
Returns
Promise<HealthResponse>
searchPlacesByTags()
searchPlacesByTags(
institutionId,
tags,
options?): Promise<MVXPlace[]>;Search places by one or more tags.
Hits the v2 endpoint GET /api/sdk/v2/searchPlacesByTags. Multiple tags are combined with OR
semantics on the server.
Sort modes:
match(default): Elastic relevance scoring.alphabetical: Sorted A→Z by place title.distance: Sorted from closest to farthest. Requires eitheroriginor the combinationlat+lng+floor+parentPlaces.
Parameters
institutionId
string
The identifier of the institution to search within.
tags
string[]
One or more tag strings to match against.
options?
(Optional) Additional filtering and sorting options.
Returns
Promise<MVXPlace[]>
A list of places that match the given tags.
Throws
Will throw if tags is empty, if sort: "distance" is used without the required positional
context, or if the request fails.
setGeoLocation()
setGeoLocation(geoLocation): void;Set the geolocation object to use for tracking the user’s location.
Parameters
geoLocation
Geolocation
the geolocation object to use for tracking the user’s location.
Returns
void
Default
navigator.geolocation if not provided.setSdkLang()
setSdkLang(lang): void;Set the language of the SDK.
Parameters
lang
string
The language to set.
Returns
void
unwatchUserHeading()
unwatchUserHeading(): void;Unregister user heading monitoring
Returns
void
unWatchUserPosition()
unWatchUserPosition(watchId): void;Unregister user location monitoring
Parameters
watchId
number
A watchId given by the watchUserPosition method
Returns
void
watchUserHeading()
watchUserHeading(onSuccess, onError): void;Watches the user’s heading and calls the provided callback with the heading value. Note: This method requires HTTPS to work properly.
Parameters
onSuccess
(heading) => void
The callback function to call with the user’s heading.
onError
(error) => void
The callback function to call if an error occurs.
Returns
void
watchUserPosition()
watchUserPosition(onSuccess, onError): number;Watches the user’s position and calls the provided callback with a custom LatLng object.
Parameters
onSuccess
The callback function to call with the user’s position.
onError
PositionErrorCallback
Returns
number
A watchId for the position watcher.