Search code examples
azureazure-maps

Azure Maps Indoor Module: Change floor without user input


I've been working with the Azure maps indoor module https://learn.microsoft.com/en-us/azure/azure-maps/tutorial-creator-indoor-maps . You can allow a user to pick a level with a level control element from the library, however I cannot figure out a way to pre-set a certain level (e.g. I want to start with a certain facility and the 2nd level pre selected when the map loads.) For the facility there is a indoorManager.setFacility() function that allows you to select a facility but I have not found the equivalent for the level.

Requirement: I want to to select a level in Azure Maps without user input.


Solution

  • There doesn't appear to be any official way to do this yet, note that Azure Maps Creator is still in preview. That said, I did figure out a hacky way around this (may break in the future).

    var facilityId = 'FCL13';
    var level = 2;
    
    //Set the facility and the levels "ordinal number". The ordinal number appears to be off by 1.
    indoorManager.setFacility(facilityId, level - 1);
    
    //Used to trigger the level control to refresh.
    map.events.invoke('moveend')