Integrating the Woosmap Indoor JS Widget

Get started with the Woosmap Indoor JS Widget. View a simple example, learn the concepts, and create custom indoor maps for your site.

Overview

The Woosmap Indoor JS Widget is an extension of the Map JS library that simplifies embedding an indoor map on your website. Widget properties are customised via a JSON configuration object passed to the constructor.

Indoor JS Widget included in the Indoor JS API

The widget lets users search for POIs, calculate the shortest path between two locations, and browse POIs grouped by level.

The widgets don’t load through importLibrary(). To enable the Indoor Widget, add the Map JS API bootstrap loader to your page with libraries: "widgets" in its parameters, then create the widget once the maps library has loaded:

HTML
        <wmp-map id="map"></wmp-map>

<script>
  async function initMap() {
    await woosmap.map.importLibrary("maps");
    const map = document.getElementById("map").innerMap;
    map.moveCamera({
      center: { lat: 48.88143952302778, lng: 2.356075199999964 },
      zoom: 17.175689366844964,
    });

    const indoorWidget = new woosmap.map.IndoorWidget();
    indoorWidget.setMap(map);
  }

  initMap();
</script>

    

IndoorWidget Configuration

The IndoorWidget constructor expects 2 parameters

Indoor Widget Options

Find its interface definition in the reference documentation: IndoorWidgetOptions Interface

Indoor Renderer Options

This constructor allows you to add an IndoorRenderer configuration JSON for setting the IndoorRenderer parameters (more information about the IndoorRenderer parameters in the dedicated section).

Find an example of how-to initialize a IndoorWidget:

JavaScript
        const indoorRendererConfiguration = {}; // Empty object = default behavior

const indoorWidgetConfiguration = {
  directionsMode: "wheelchair", // Apply a default routing profile
  units: "metric", // Define the distance unit for route distance calculation
};

const indoorWidget = new woosmap.map.IndoorWidget(indoorWidgetConfiguration, indoorRendererConfiguration);

indoorWidget.setMap(myMap);

    

Below you can see a sample usage of a Woosmap Indoor JS Widget displaying Woosmap Office in Montpellier (France).

How-to implement Navigation Widget

After calculating the shortest route thanks to the Indoor Direction Service, you can start the navigation widget to offer a better user navigation experience. This widget provides navigation instruction and guides the user from their location to their destination:

JavaScript
        const indoorService = new window.woosmap.map.IndoorService();

indoorService.directions(
  {
    venueId: indoorRenderer.getVenue().venue_id,
    origin: new woosmap.map.LatLng(x.latlng),
    originLevel: 0,
    destination: new woosmap.map.LatLng(y.latlng),
    destinationLevel: 0,
    language: "en",
    units: "metric",
    mode: "wheelchair",
  },
  (result) => {
    indoorRenderer.setDirections(result);
    indoorNavigation = new woosmap.map.NavigationWidget(indoorRenderer, exitNavigation);
    indoorNavigation.setMap(myMap);
  }
);

const exitNavigation = () => {
  indoorNavigation.setMap(null);
  indoorNavigation = null;
  indoorRenderer.setDirections(null);
};

    
Was this helpful?