HERE Indoor Map offers high quality maps modeling indoor spaces, including building geometry and points of interest spanning across multiple floors. For more information about Here Indoor Map, refer to the HERE Indoor Map User Guide.
This tutorial provides information on how to integrate and use HERE Indoor Map in the Maps API.
Pre-requisites for integrating HERE Indoor Map
The following pre-requisites are required to integrate HERE Indoor Map in the Maps API:
The app credentials must have access to the requested indoor map, and the catalog HRN of the catalog containing the relevant indoor maps is required.
Include the HERE Indoor Map module script in the <head> section of the HTML page:
To create and display data on a map, follow the procedures outlined in Get started.
Creating an instance of the Service
Use the platform object to get the instance of H.venues.Service2 (venues.Service2 provides the latest service on Platform) to load your Indoor Maps and create a H.venues.Provider object to control the loaded Indoor Maps. Refer to H.service.Platform.getVenuesService to get more details on service instantiation.
There are two ways of creating an instance, with and without a valid Indoor Map collection HRN.
Creating an instance of the Service without a collection HRN
It is required to set a valid OAuth token value when HRN is not provided, otherwise the H.venues.Service2 will not work. This link contains more information on how you can get a valid OAuth tokens on the HERE platform.
// Get instance of the Indoor Maps service// The second parameter 'opt_version' signifies the venues version. // 2 = latest venue service, 1 = legacy serviceconst venuesService = platform.getVenuesService({token:"Platform token"},2);
Creating an instance of the Service with a collection HRN
It is required to set a valid HRN value, otherwise the H.venues.Service2 will not work. This link contains more information on how you can get a valid HRN string for your project. When HRN is provided, additionally either a HERE Platform API key or token is required.
// Get instance of the Indoor Maps service// The second parameter 'opt_version' signifies the venues version. // 2 = latest venue service, 1 = legacy serviceconst venuesService = platform.getVenuesService({apikey:'API KEY',hrn:'Platform hrn for indoor maps catalog'},2);
Fetching list of all available Indoor maps
The H.venues.Service2 object provides Indoor Maps info list through the getMapInfoList method. This function will retrieve a list of available Indoor maps from the given HRN.
// Get a list of indoor maps
venuesService.getMapInfoList().then((res)=>{
console.log("Indoor Maps: ", res)}).catch((e)=>{
console.error("Error when fetching map list", e)})
Loading the Indoor Map
Use the instance of H.venues.Service2 (venues.Service2 provides the latest service on Platform) to load your Indoor Maps and create a H.venues.Provider object to control the loaded Indoor Maps. Refer to H.service.Platform.getVenuesService to get more details on service instantiation.
// Indoor Maps provider interacts with a tile layer to visualize and control the Indoor Mapconst venuesProvider =newH.venues.Provider();// Indoor Maps service provides a loadVenue method
venuesService.loadVenue(VENUE_ID).then((venue)=>{// add Indoor Map to the venues provider
venuesProvider.addVenue(venue);
venuesProvider.setActiveVenue(venue);// create a tile layer for the Indoor Maps provider
map.addLayer(newH.map.layer.TileLayer(venuesProvider));// center the map on the Indoor Map
map.setCenter(venue.getCenter());
map.setZoom(15);});
Figure 1. Example of a HERE Indoor Map
The example above shows a HERE Indoor Map on a map.
Changing levels
The Provider facilitates the control of the indoor map. Set the following to retrieve information about the current level or change the level:
// Get active Indoor Mapconst venue = venuesProvider.getActiveVenue();// get current level index
venue.getActiveLevelIndex();// and change level
venue.setActiveLevelIndex(1);
Overriding label preferences
To override the default label preferences, set the value for labelTextPreferenceOverride from H.venues.Service2.LABEL_TEXT_PREFERENCE_OVERRIDE in H.venues.Service2:
// This is an option to override label preference. // If both space name and address are available for a given space, they will take priority over the rest of labels, in the given order.const labelTextPreferenceOverride =[H.venues.Service2.LABEL_TEXT_PREFERENCE_OVERRIDE.SPACE_NAME,H.venues.Service2.LABEL_TEXT_PREFERENCE_OVERRIDE.INTERNAL_ADDRESS]// Indoor Maps service provides a loadVenue method
venuesService.loadVenue(VENUE_ID,{ labelTextPreferenceOverride }).then((venue)=>{// add Indoor Map to the venues provider
venuesProvider.addVenue(venue);
venuesProvider.setActiveVenue(venue);// create a tile layer for the Indoor Maps provider
map.addLayer(newH.map.layer.TileLayer(venuesProvider));});
Search functionality
The H.venues.Venue object provides search functionality through the search method. The search string is not case sensitive and also looks for close matches:
// Get the active Indoor Mapconst venue = venuesProvider.getActiveVenue();// Search for bathrooms
venue.search('Bathroom');
HERE Indoor Map user interface
Default user interface elements control Drawings and Levels using H.venues.ui.DrawingControl and H.venues.ui.LevelControl:
// Get the active Indoor Mapconst venue = venuesProvider.getActiveVenue();// Create the level controlconst levelControl =newH.venues.ui.LevelControl(venue);
ui.addControl('level-control', levelControl);// Create the drawing control:const drawingControl =newH.venues.ui.DrawingControl(venue);
ui.addControl('drawing-control', drawingControl);
HERE Indoor Map objects
HERE Indoor Map data is encapsulated in a hierarchy of objects. These objects perform the same as other MapObjects, and are represented by the following classes:
H.venues.Venue
H.venues.Drawing
H.venues.Level
H.venues.Geometry
The root is Venue, which contains one or more Drawings, which contains one or more Levels. And the Level object holds the relevant collection of Geometry objects. The raw data associated with each object is accessible through the getData() method. The classes extend H.map.Feature.