# new MapsIndoors(options)
Constructs a new MapsIndoors instance.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
object
|
Configuration options for the MapsIndoors instance. |
||
mapView |
mapsindoors.mapView.GoogleMapsView
|
mapsindoors.mapView.MapboxView
|
An instance of a MapView. |
||
venue |
string
|
<optional> |
The ID of the initial venue. Optional. |
|
floor |
number
|
string
|
<optional> |
The index of the initial floor. Optional. |
|
buildingOutlineOptions |
BuildingOutlineOptions
|
<optional> |
Settings for the polygon outlining the building in focus. Optional. |
|
labelOptions |
LabelOptions
|
<optional> |
Styling options for labels on the map. Optional. |
|
floorSelectionMode |
'manual'
|
'automatic'
|
<optional> |
'automatic' | Sets the floor selection mode. Can be 'automatic' or 'manual'. Defaults to 'automatic'. |
buildingSelectionMode |
'manual'
|
'automatic'
|
<optional> |
'automatic' | Sets the building selection mode. Can be 'automatic' or 'manual'. Defaults to 'automatic'. |
- MapsIndoors#event:building_changed
- MapsIndoors#event:click
- MapsIndoors#event:mouseenter
- MapsIndoors#event:mouseleave
- MapsIndoors#event:floor_changed
- MapsIndoors#event:ready
- MapsIndoors#event:venue_changed
- MapsIndoors#event:zoom_changed
Example
new mapsindoors.MapsIndoors({
mapView: mapsindoors.mapView.GoogleMapsView|mapsindoors.mapView.MapboxView
});
Members
function
# static onAuthRequired
The onAuthRequired property is an EventHandler that processes the AuthRequired event. The AuthRequired is raised when authentication is required for the requested solution.
Example
mapsindoors.MapsIndoors.onAuthRequired = () => {...};
Methods
# deallocate()
Clean up and release resources associated with this MapsIndoors instance. This includes event bindings and other internal ressources. Use this method when you are done using the instance and wish to ensure that it no longer consumes browser resources. Afterwards, you must not call any other methods on the instance.
# filter(filter, fitView)
Filter locations on the map by array of ids
Parameters:
Name | Type | Description |
---|---|---|
filter |
Array.<string>
|
An array of location ids to filter the map by. |
fitView |
boolean
|
Change the map viewport to fit the current filter. |
# fitBuilding(buildingopt, optionsopt) → {Promise}
Fits a building's geometry in the map's bounding box.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
building |
Building
|
string
|
<optional> |
building (object or id). If not given, the currently set building will be used. |
|
options |
Object
|
<optional> |
Optional parameters. |
|
padding |
number
|
<optional> |
0 | Padding around the building when fitting the map view. (Optional) |
maxZoom |
number
|
<optional> |
Maximum zoom level to use when fitting the map view. (Optional) |
Promise
# async fitVenue(venueopt, optionsopt) → {Promise}
Fits a venue's geometry in the map's bounding box.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
venue |
Venue
|
string
|
<optional> |
venue (object or id). If not given, the current venue will be used. |
|
options |
Object
|
<optional> |
Optional parameters. |
|
padding |
number
|
<optional> |
0 | Padding around the venue when fitting the map view. (Optional) |
maxZoom |
number
|
<optional> |
Maximum zoom level to use when fitting the map view. (Optional) |
Promise
# getBuildingSelectionMode() → {'manual'|'automatic'}
Retrieves the building selection mode.
The building selection mode, either 'automatic' or 'manual'.
'manual'
|
'automatic'
# getDirectionsRenderer() → {DirectionsRenderer}
Returns the DirectionsRenderer instance. The DirectionsRenderer is responsible for rendereing routes on the map.
DirectionsRenderer
# getDisplayRule(target, ignoreOverridesopt) → {DisplayRule}
Gets the DisplayRule for a given location
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
target |
Location
|
|||
ignoreOverrides |
boolean
|
<optional> |
false | When true the display rule is returned without the overrides. |
# getFloorSelectionMode() → {'manual'|'automatic'}
Retrieves the floor selection mode.
The floor selection mode, either 'automatic' or 'manual'.
'manual'
|
'automatic'
# getLocationSettings(location) → {LocationSettings}
Gets the LocationSettings for a given location.
Parameters:
Name | Type | Description |
---|---|---|
location |
Location
|
- The LocationSettings for the given location, merged from the location, location type and solution config.
# getMap() → {google.maps.Map|mapboxgl.Map}
Gets the current map instance.
google.maps.Map
|
mapboxgl.Map
# getMapIndoorsStyles() → {Array.<MapStyle>}
Gets a list of available MapsIndoors map styles.
Array.<MapStyle>
# getMapView(mapView)
Gets the map view. The map view is the adapter between the SDK and the specific map provider. This could be Google Maps or MapBox.
Parameters:
Name | Type | Description |
---|---|---|
mapView |
*
|
MapView
# getMaxZoom() → {number}
Gets the MapsIndoors current max zoom level. This function gets a normalized zoom level. Due to the difference in zoom levels between map providers is recommended to use this function to get the max zoom level as it returns a normalized max zoom level. The SDK uses the normalized zoom level for evaluating DisplayRules.
number
# getStatefulDisplayRule(target, ignoreOverridesopt) → {DisplayRule}
Gets the stateful display rule for a given location. A stateful display rule is a display rule that is combined with the location's current state display rule.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
target |
Location
|
|||
ignoreOverrides |
boolean
|
<optional> |
false | When true the display rule is returned without the overrides. |
# getZoom() → {number}
Gets the MapsIndoors zoom level. This function gets a normalized zoom level. Due to the difference in zoom levels between map providers is recommended to use this function to get the zoom level as it returns a normalized zoom level. The SDK uses the normalized zoom level for evaluating DisplayRules.
number
# goTo(feature, optionsopt) → {Promise}
Fits the map view to the given feature with optional padding and maximum zoom level.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
feature |
GeoJSON.Feature
|
GeoJSON.Geometry
|
The feature to fit the map view to. |
||
options |
Object
|
<optional> |
Optional parameters. |
|
padding |
number
|
Padding
|
<optional> |
0 | Padding around the feature when fitting the map view. (Optional) |
maxZoom |
number
|
<optional> |
Maximum zoom level to use when fitting the map view. (Optional) |
A promise that resolves when the map view has been fitted to the feature.
Promise
# highlight(ids, fitView)
Highlight locations on the map by array of ids.
Parameters:
Name | Type | Description |
---|---|---|
ids |
Array.<string>
|
An array of location ids to highlight on the map. |
fitView |
boolean
|
Change the map viewport to fit the current filter. |
# hoverLocation(location)
Sets the Location to be hovered. (Until another Location is hovered, either by calling this method again or by moving the mouse).
Parameters:
Name | Type | Description |
---|---|---|
location |
Location
|
The Location be hovered. |
# overrideDisplayRule(target, displayRule)
Will override the default display rule for the target.
Parameters:
Name | Type | Description |
---|---|---|
target |
string
|
Array.<string>
|
Target id (type or location). |
displayRule |
DisplayRule
|
The display rule. |
# revertDisplayRule(target)
Reverts one or more overridden display rule(s).
Parameters:
Name | Type | Description |
---|---|---|
target |
string
|
Array.<string>
|
Target id (type or location). |
# selectLocation(location)
Select a Location.
Parameters:
Name | Type | Description |
---|---|---|
location |
Location
|
The Location be selected. |
# setBuilding(building) → {void}
Sets the building in focus.
Parameters:
Name | Type | Description |
---|---|---|
building |
Building
|
void
# setBuildingOutlineOptions(options)
Sets the building outline options
Parameters:
Name | Type | Description |
---|---|---|
options |
BuildingOutlineOptions
|
# setBuildingSelectionMode(mode)
Sets the building selection mode.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
mode |
'manual'
|
'automatic'
|
automatic | The building selection mode. Defaults to 'automatic'. |
# setDisplayRule(target, displayRule)
Sets a DisplayRule for one or more types or locations
Parameters:
Name | Type | Description |
---|---|---|
target |
string
|
Array.<string>
|
Can be a single location id or type name, or an array of locations ids and type names. |
displayRule |
DisplayRule
|
# setFloorSelectionMode(mode)
Sets the floor selection mode.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
mode |
'manual'
|
'automatic'
|
automatic | The floor selection mode. Defaults to 'automatic'. |
# setLabelOptions(opts)
Sets the label options used for rendering labels on the map.
Parameters:
Name | Type | Description |
---|---|---|
opts |
LabelOptions
|
# setLocationSettings(target, locationSettings)
Sets the LocationSettings for one or more locations or location types.
Parameters:
Name | Type | Description |
---|---|---|
target |
Location
|
Array.<Location>
|
string
|
Array.<string>
|
The target can be a single Location object, an array of Location objects, a single location id, an array of location ids, or type names. |
locationSettings |
LocationSettings
|
The LocationSettings to set. |
Example
// Sets the LocationSettings:
mapsIndoors.setLocationSettings('type', { selectable: false });
mapsIndoors.setLocationSettings(['locationId1', 'locationId2'], { selectable: false }));
// Resets the LocationSettings:
mapsIndoors.setLocationSettings('type', null);
mapsIndoors.setLocationSettings(['locationId1', 'locationId2'], null);
# setMapView(mapView)
Sets the map view. The map view is the adapter between the SDK and the specific map provider. This could be Google Maps or MapBox.
Parameters:
Name | Type | Description |
---|---|---|
mapView |
*
|
# setMapsIndoorsStyle(mapStyle)
Sets the map style.
Parameters:
Name | Type | Description |
---|---|---|
mapStyle |
MapStyle
|
# setSolutionConfig(solutionConfig)
Sets the solution config.
Parameters:
Name | Type | Description |
---|---|---|
solutionConfig |
SolutionConfig
|
Solution Config object. |
# setZoom(zoom)
Sets the MapsIndoors zoom level. This function sets the map zoom level. Due to the difference in zoom levels between map providers is recommended to use this function to set the zoom level as it normalizes the zoom level across different map providers. The SDK uses the normalized zoom level for evaluating DisplayRules.
Parameters:
Name | Type | Description |
---|---|---|
zoom |
number
|
# static addVenuesToSync(venueIds)
Set one or more venues to sync location data for.
Parameters:
Name | Type | Description |
---|---|---|
venueIds |
string
|
Array.<string>
|
An array of venue ids. |
# static disableEventLogging(boolean)
Enable or disable the SDK logging.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
boolean |
boolean
|
true | A boolean to enable or disable the SDK logging. |
# static getUserRoles() → {Array.<UserRole>}
Gets the user roles that will be applied when querying routes and locations.
- Array of UserRoles.
Array.<UserRole>
# static removeVenuesToSync(venueIds)
Remove one or more venues from the synced data.
Parameters:
Name | Type | Description |
---|---|---|
venueIds |
string
|
Array.<string>
|
An array of venue ids. |
# static setAuthToken(authToken)
Sets the MapsIndoors authentication token. The token is required for retriving data from solutions behind a login.
Parameters:
Name | Type | Description |
---|---|---|
authToken |
string
|
# static setLanguage(language)
Sets a language for mapsindoors.
Parameters:
Name | Type | Description |
---|---|---|
language |
string
|
# static setMapsIndoorsApiKey(apiKey)
Sets a new mapsindoors api key.
Parameters:
Name | Type | Description |
---|---|---|
apiKey |
string
|
# static setUserRoles(userRoles)
Sets the user roles that will be applied when querying routes and locations.
Parameters:
Name | Type | Description |
---|---|---|
userRoles |
UserRole
|
Array.<UserRole>
|
One or more UserRoles. |
Example
mapsindoors.services.SolutionsService.getUserRoles().then(userRoles => {
const roles = userRoles.filter(role => ["Maintenance", "Staff"].includes(role.name));
mapsindoors.MapsIndoors.setUserRoles(roles);
});
Events
# building_changed
This event will fire if the building focus changes after the map has moved or by calling mapsIndoors.fitBuilding(building)
.
Properties:
Name | Type | Description |
---|---|---|
building |
Building
|
Example
mapsIndoors.addListener('building_changed', (building) => {...});
# building_outline_changed
This event will fire when the style for the building outline has changed.
Example
mapsIndoors.addListener('building_outline_changed', () => {...})
Object
# click
This event will fire when a location is clicked on the map.
Properties:
Name | Type | Description |
---|---|---|
location |
Location
|
Example
mapsIndoors.addListener('click', (location) => {...});
# floor_changed
This event will fire when the floor index has changed.
The floor index can be changed by calling mapsIndoors.setFloor(index)
or through interaction with the FloorSelector.
Properties:
Name | Type | Description |
---|---|---|
floorIndex |
number
|
Example
mapsIndoors.addListener('floor_changed', (floorIndex) => {...});
# label_options_changed
This event will fire when the style for the labels has changed.
Example
mapsIndoors.addListener('label_options_changed', () => {...})
Object
# mouseenter
This event will fire when the cursor of a pointing device is moved so it is within the bounds of a Location.
Properties:
Name | Type | Description |
---|---|---|
location |
Location
|
Example
mapsIndoors.addListener('mouseenter', (location) => {...});
Object
# mouseleave
This event will fire when the cursor of a pointing device is moved so it leaves the bounds of a Location.
Properties:
Name | Type | Description |
---|---|---|
location |
Location
|
Example
mapsIndoors.addListener('mouseleave', (location) => {...});
# ready
This event will fire when MapsIndoors has been initilaized and is ready.
Example
mapsIndoors.addListener('ready', () => {...});
# redraw
This event will fire when a display rule or location was changed, and the changes were reflected on the map.
Example
mapsIndoors.addListener('redraw', () => {...})
# venue_changed
This event will fire if the venue changes after calling mapsIndoors.setVenue(venue|venueId)
.
Properties:
Name | Type | Description |
---|---|---|
venue |
Venue
|
Example
mapsIndoors.addListener('venue_changed', (building) => {...});
# zoom_changed
This event will fire when the map zoom level has changed. Due to the difference in zoom levels between map providers is recommended to listen to this event as the zoom level in the event payload is normalized across different map providers. The SDK uses the normalized zoom level for evaluating DisplayRules.
Properties:
Name | Type | Description |
---|---|---|
zoomLevel |
number
|
A normalized MapsIndoors zoom level. |
Example
mapsIndoors.addListener('zoom_changed', (zoomLevel) => {...});