05 – Using Situm SDK & Situm WYF together

Table of Contents

Traditionally, Situm WYF and Situm SDK could be used together but under a somewhat limited fashion. Essentially, if your application started positioning using Situm SDK, you needed to stop Situm SDK manually before loading Situm WYF. Then, Situm WYF would start Situm positioning on its own. If you unloaded Situm WYF, positioning would stop and you needed to re-start it again using Situm SDK.

This situation was not ideal, so from version 0.25.0 (Android) & 0.19.0 (iOS) onwards Situm SDK included in the LocationManager (Android, iOS) a new method called addLocationListener/addDelegate (Android, iOS). This method allows you to subscribe a new LocationListener/LocationDelegate (Android, iOS) to Situm SDK positioning.

If positioning is already running and you start Situm WYF, it will draw the user position immediately and will not need to restart positioning anymore. Situm WYF will act similarly at any time if the positioning stops or starts from the outside (using the Situm SDK API directly).

Warning! In Android, any call to method requestLocationUpdates(LocationRequest, LocationListener) will prevent Situm WYF from working correctly.

You may desubscribe at any time using the removeLocationListener/removeDelegate (Android, iOS) or removeAllLocationListeners (Android only) methods, and stop positioning using the removeUpdates (Android, iOS) and removeUpdates(LocationListener) (Android only) methods.

Code example #

Let’s look at the hypothetical case of an app that starts Situm positioning as soon as it is launched. This app also integrates Situm WYF on a specific screen to show the map, user position and allow navigation:

  1. First, we configure Situm SDK and subscribe to the geolocations that it will produce. Then, we start positioning.
  2. Under a call to loadWYF(), the app displays the WYF module. Situm WYF registers (internally) its own LocationListener, receiving every location and status change.
  3. Therefore, Situm WYF knows that the positioning was already started and will show the user position immediately. Situm WYF will react coherently when calling stopPositioning() and startPositioning() at any time. For instance, the user location will not be shown if the app stops positioning.

public class MainActivity extends AppCompatActivity {
    // First, declare a LocationListener. This will receive the computed geolocations, status changes and errors.
    private LocationListener locationListener = new LocationListener() {

    // Declare the SitumMapsLibrary (WYF)
    SitumMapsLibrary mapsLibrary = null;

    protected void onCreate(Bundle savedInstanceState) {
        // Initialize SitumSDK and start positioning (see https://situm.com/docs/mobile-sdks-positioning/).
        // Use the addLocationListener method to receive location updates on your LocationListener implementation
        // Start positioning:

    public void startPositioning() {

        // Build the LocationRequest, ask for permissions ...
        LocationRequest locationRequest = new LocationRequest.Builder().build();

        // Start positioning, passing only the desired configuration (LocationRequest).
        // No need to pass the LocationListener object because it was already registered

    public void stopPositioning() {
        // Use the method removeUpdates() (without parameters).
        // This will keep all the LocationListeners previously subscribed.

    public void loadWYF() {
        // This will be called somewhere in your app (e.g. from a tab navigator)
        // Setups and loads WYF as explained in https://situm.com/docs/android-quickstart-guide/

        LibrarySettings librarySettings = new LibrarySettings();
class ViewController: UIViewController {
    // View where the library will be loaded
	@IBOutlet var containerView: UIView!
    // Declare the SitumMapsLibrary (WYF)
    var library: SitumMapsLibrary?
    override func viewDidLoad() {
        // Setups WYF as explained in https://situm.com/docs/ios-quickstart-guide/        
        let settings = LibrarySettings.Builder().build()      
        library = SitumMapsLibrary(containedBy: containerView, controlledBy: self, withSettings: settings)
        // Configure Situm SDK explained in https://situm.com/docs/a-basic-swift-ios-app/      
        SITServices.provideAPIKey("SET YOUR APIKEY HERE", forEmail: "SET YOUR EMAIL HERE")
        // Use the addDelegate method to receive location updates. See extension below this class
    func startPositioning() {
        // Build the SITLocationRequest, ask for permissions ...    
        // Check the quickstart guide for SitumSDK  https://situm.com/docs/a-basic-swift-ios-app/
        let request = SITLocationRequest()
        // Start positioning, passing only the desired configuration (SITLocationRequest)   
    func stopPositioning() {
        // Use the method removeUpdates()     
        // This will keep all the LocationListeners previously subscribed.   
    func loadWYF() {
        // This will be called somewhere in your app (e.g. from a tab navigator)    
        do {   
            try self.library!.load()   
        } catch {          
        print("An error has ocurred. Your SitumView could not be loaded.")   

    private func unloadWYF(){
        //This will be called somewhere in your code to release the resources Wayfinding is using
        //This is specially important to guarantee proper working if you plan to load a new instance of Wayfinding (for instance to show a different building)

// Declare an extension of SITLocationDelegate. This will receive the computed geolocations, status changes and errors.

extension ViewController: SITLocationDelegate {   
  func locationManager(_ locationManager: SITLocationInterface, didInitiatedWith request: SITLocationRequest) {} 
  func locationManager(_ locationManager: SITLocationInterface, didUpdate location: SITLocation) {}  
  func locationManager(_ locationManager: SITLocationInterface, didFailWithError error: Error?) {}    
  func locationManager(_ locationManager: SITLocationInterface, didUpdate state: SITLocationState) {}

Subscribe to our newsletter


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