06 – Dynamic UI settings

Please note! All the code snippets in this section have been provided for Android. If you use iOS, Cordova or ReactNative you’ll find it easy to translate them appropriately.

SitumWYF allows you to configure several aspects of the User Interface. In a previous Section, we have seen that some of these aspects are configured before SitumWYF is loaded (static UI settings). In this section, we will focus on the dynamic UI settings, that can be changed on-the-fly.

All the dynamic UI settings MUST be configured after SitumWYF is loaded. To that extent, in Android a SitumMapsListener needs to be passed to SitumMapsLibrary setSitumMapsListener method. In iOS, you may do the same by passing an OnMapReadyListener delegate to called setOnMapReady. This listener will be called when SitumWYF loads correctly, and after that we can apply the appropriate dynamic configurations on the fly. The following example shows how to do it on Android:

public class MainActivity extends AppCompatActivity {
    private static final String TAG = MainActivity.class.getSimpleName();

    SitumMapsLibrary mapsLibrary = null;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //Create LibrarySettings and set the account credentials
        LibrarySettings librarySettings = new LibrarySettings();
        librarySettings.setApiKey("EMAIL", "APIKEY");

        mapsLibrary = new SitumMapsLibrary(R.id.maps_library_target, this, librarySettings);

        //Set the SitumMapsListener, which will apply the Dynamic UI configurations
        // after SitumWYF loads
        mapsLibrary.setSitumMapsListener(mapsListener);
        mapsLibrary.load();
    }

    private SitumMapsListener mapsListener = new SitumMapsListener() {
        @Override
        public void onSuccess() {

            //Configure dynamic UI settings after SitumWYF view loads correctly
            mapsLibrary.centerBuilding("12485", null);
            mapsLibrary.setFloorsListVisible(false);
            mapsLibrary.setInfoViewVisible(false);
        }

        @Override
        public void onError(int i) {
            Log.d(TAG, "Error!");
        }
    };
}

Camera controls #

Center on a building #

If you want to provide wayfinding in a certain building, it’s a good idea to center the view automatically in it. You may do this when the module starts, when the user presses a certain button or selects the building from a dropdown, etc.

You may do so by using the method centerBuilding (Android only) from SitumMapsLibrary. Here’s an example showing how to do it in Android:

public class MainActivity extends AppCompatActivity {
  ...
     private SitumMapsListener mapsListener = new SitumMapsListener() {
        @Override
        public void onSuccess() {

            //Centers the view on building "12485"
            mapsLibrary.centerBuilding("12485", null);    
            ...   
        }

       ...
    };
}

And here’s the result:

Note that this method simply centers the view on the venue, but does not restrict the camera movement to a certain zoom level or enclosing boundaries. Therefore, the user can still move freely around the world. If you want to restrict the camera movement to a certain building, read next section.

Info! In Android, the centerBuilding method receives a second parameter (null in our example) of type ActionsCallback. ActionsCallback informs about the state of execution of the method (e.g. you may want to do something in your app when the view finishes centering on the building).

Block the camera to a building’s bounds (one building mode) #

Sometimes, it’s a good idea to restrict the movement of the camera to that specific building bounds. To this extent, you may use the method enableOneBuildingMode in enableOneBuildingMode in Android in lockCameraToBuilding in iOS from SitumMapsLibrary. You may disable this mode again by using the method releaseOneBuildingMode (Android) or unlockCamera (iOS).

Here’s an example showing how to do it in Android:

public class MainActivity extends AppCompatActivity {
  ...
     private SitumMapsListener mapsListener = new SitumMapsListener() {
        @Override
        public void onSuccess() {

            //Locks the view to the building "12485"
            mapsLibrary.enableOneBuildingMode("12485");     
            ...       
        }

       ...
    };
}

And here’s the result:

Tip! The boundaries are automatically calculated depending on the size of the building and the minimum zoom level. Therefore, if you modify the minimum zoom level, you may modify the boundaries to your liking.

POI filtering by category #

If you have many POIs in your venue, it might prove difficult to find a certain one. Sure, the user has the search bar… but oftentimes it’s just more comfortable to find them by looking at the map. To help you achieve this, SitumWYF implements the filterPoisBy method (Android, iOS) on SitumMapsLibrary.

For example, the following Android example will only show categories with IDs “1” (Coffee), “2” (Elevator) and “4” (Information), leaving the rest of the POIs out.

public class MainActivity extends AppCompatActivity {
  ...
     private SitumMapsListener mapsListener = new SitumMapsListener() {
        @Override
        public void onSuccess() {

            //Filter out every category but "1" (Coffee), "2" (Elevator) and "4" (Information)
            List<String> categories = Arrays.asList("1", "2", "4");
            mapsLibrary.filterPoisBy(categories);
            ...
        }

       ...
    };
}

Here’s the result:

Tip! You may know the IDs of your POI categories by using REST API or Situm SDK.

Hide UI elements (Android only) #

You may hide and show dynamically several UI elements:

  • Floor selector: allows change the floor whose map & POIs are shown. The setFloorListVisible method from SitumMapsLibrary is used.
  • Building / POI information footer: displays the name of the building or the POI that has been selected. The setInfoViewVisible method from SitumMapsLibrary is used.
  • Positioning FAB (Floating Action Button): to start & stop positioning. The setPositioningFabVisible method from SitumMapsLibrary is used.
  • Routing FAB: to start a route to a selected destination (e.g. a POI). The setGetMeToPoiFabVisible method from SitumMapsLibrary is used.

This is useful if you want to implement your own UI components or custom-behaviours on top of SitumWYF. For instance:

  • Implement your own floor selector with your own design.
  • Provide the full HTML information on a pop-up when the user clicks on a POI.
  • Auto-start positioning and don’t allow the user to stop it by hiding the positioning FAB.

The following Android snippet illustrates how to control whether the UI elements are hidden or shown:

public class MainActivity extends AppCompatActivity {
  ...
     private SitumMapsListener mapsListener = new SitumMapsListener() {
        @Override
        public void onSuccess() {

            //Hide the floor selector, the POI info footer
            // and the positioning and routing FABs
            mapsLibrary.setFloorsListVisible(false);
            mapsLibrary.setInfoViewVisible(false);
            mapsLibrary.setGetMeToPoiFabVisible(false);
            mapsLibrary.setPositioningFabVisible(false);
            ...
        }

       ...
    };
}

Here’s an example showing the difference:

UI elements are shown
UI elements have been hidden

Subscribe to our newsletter

BASIC INFORMATION ON DATA PROTECTION

Data controller: SITUM TECHNOLOGIES, S.L.
Contact: Data controller: situm@situm.es
Responsible for protection: dpo@situm.es
Purpose and legal basis: To manage the sending of SITUM newsletters only with consent.
Legitimation: Express consent of the interested party.
Recipients: The data will not be passed on to third parties with the exception of legal obligations.
Retention period: As long as the interested party remains subscribed to the newsletter (a link to unsubscribe will be available in each newsletter sent by Situm).
Rights: The interested party may at any time revoke their consent, as well as exercise their rights of opposition, access, conservation, rectification, limitation, deletion of data and not be subject to a decision based only on automated data processing, by writing to SITUM at the addresses indicated.
Additional Information: You can consult additional and detailed information on Data Protection in our privacy policy.

Please, download your copy here

Thank you for downloading our whitepaper. Please do not hesitate to contact us if you would like to know more about how our solutions can help your business. Download whitepaper


Close window