ARwayKit SDK
❱ HOMEPAGE⚎ DEVELOPER PORTAL
  • Introduction
  • Change Log
  • FAQ
  • ARWAY SDK
    • Getting Started
    • Building from the Source Code
    • Integrating the Unity Package
    • Managing App Localizations
      • Enabling Right-to-Left (RTL) Text
    • Sample Scenes
      • Dashboard
      • AR Map Session
    • Branding the Sample App
      • Replacing ARway Logos in the Sample App
    • Third Party
    • SDK Upgrade Guide
      • 3.1.0 -> 3.1.4
      • 3.0.1 -> 3.1.0
      • 3.0.0 -> 3.0.1
      • 2.5.1 -> 3.0.0
      • 2.3.1 -> 2.5.1
      • 2.3 -> 2.3.1
    • Enhancing the Sample App
      • Instant Location Pin Navigation
      • Customizing the Default Navigation Arrow
      • Initializing AR Using an IAP
  • Maps Studio
    • Overview
    • Maps Studio
      • Creating a Map
      • Editing Map Details
      • Uploading Content
      • QR Codes
      • Image Access Points (IAPs)
      • Floorplans
      • Using the Editor
      • Occlusion
      • Analytics
  • ARwayKit SDK Integrations
    • Flutter
      • Quickstart in Flutter
    • React Native
      • Quickstart in React Native
    • Android Kotlin
      • Quickstart in Android Kotlin
    • Android Java
      • Quickstart in Android Java
    • iOS Swift
      • Quickstart in iOS Swift
  • Deep Linking
    • What is Deep Linking?
    • Creator Portal Changes
    • Modifying the SDK
    • Configuring Server Files
  • DEVELOPER FEEDBACK
    • Support
Powered by GitBook
On this page
  • Triggering the Location Pin Path Preview
  • Example 1: Passing Location Pin Information from the Scene
  • Selecting a Location Pin from the Creator Portal
  • Modifying the SDK Code
  • Example 2: Using the Anchor Description
  • Edit the Description of an Anchor to Include a Location Pin Name
  • Modifying the SDK Code
  1. ARWAY SDK
  2. Enhancing the Sample App

Instant Location Pin Navigation

Immediately open the location pin navigation preview after scanning the QR code

PreviousEnhancing the Sample AppNextCustomizing the Default Navigation Arrow

Last updated 1 year ago

This page will showcase how to add in the feature to open the location pin path preview after scanning the QR code.

Triggering the Location Pin Path Preview

In the scene "ARMapSession" you can trigger the location pin path preview with the following code:

WindowManager.Instance.OpenPanel("LocationpinViewerPanel");
LocationpinViewer.Instance.OpenLocationDetails(location);
LocationpinViewer.Instance.GetDirection();

We use the existing WindowManager and LocationPinViewHandler to open the panels required for the path preview.

Example 1: Passing Location Pin Information from the Scene

Selecting a Location Pin from the Creator Portal

The first thing we need to do is acquire a value from the location pin that we can reference. You can choose from the following location pin values: id, name, description, or notes.

In this example, we'll use the "notes" section, located under the "Advanced Settings" when selecting the location pins.

Modifying the SDK Code

Modifying the "Dashboard" Scene

You can add a new function to save a value to the PlayerPrefs that can be fetched when the "ARMapSession" scene is opened.

public void OpenLocationPinPreview(string destinationValue)
{
    // Find the MapsInfoManager GameObject
    GameObject mapsInfoManagerObject = GameObject.Find("MapsInfoManager");

    if (mapsInfoManagerObject != null)
    {
        // Attempt to get the MapsInfoManager component
        MapsInfoManager mapsInfoManager = mapsInfoManagerObject.GetComponent<MapsInfoManager>();

        if (mapsInfoManager != null)
        {
            // Set destination value in PlayerPrefs
            PlayerPrefs.SetString("NavToValue", destinationValue);
            PlayerPrefs.Save();

            // Start AR session
            mapsInfoManager.StartARSession(true);
        }
    }
}

Modifying the "ARMapSession" Scene

In the file "Assets/ARway/ViewerMode/2_Scripts/SDK/ARMapLoader.cs" add the following function:

public void CheckForNavTo()
{
    if (!PlayerPrefs.HasKey("NavToValue"))
    {
        return;
    }

    string navToValue = PlayerPrefs.GetString("NavToValue");
    PlayerPrefs.DeleteKey("NavToValue");
    PlayerPrefs.Save();

    Dictionary<string, LocationPinUi> locationPinsWithID = ContentStorageManager.Instance.m_LocationPinsWithID;

    foreach (KeyValuePair<string, LocationPinUi> pair in locationPinsWithID)
    {
        string id = pair.Key;
        LocationPinUi locationPinUi = pair.Value;
        string note = locationPinUi.locationPin.advanced.note;
        if (!string.IsNullOrEmpty(note) && note == navToValue)
        {
            LocationPinUi? location = ContentStorageManager.Instance.m_LocationPinsWithID[id];
            if (location != null)
            {
                WindowManager.Instance.OpenPanel("LocationpinViewerPanel");
                LocationpinViewer.Instance.OpenLocationDetails(location);
                LocationpinViewer.Instance.GetDirection();
            }
        }
    }
}

Then, include the function call at the end of LoadLocationpinContent, around line 111.

...
    #region WayPointContent
    foreach (Waypoint3d tour in arContent.waypoints3ds)
    {
        ContentStorageManager.Instance.LoadNavigationTour(tour);
    }
    #endregion    
+   CheckForNavTo();  
}
...     

Then in that same file, add the following to line #5:

using System.Collections.Generic;

Then, on line #15, add the following line PlayerPrefs.SetInt("ArwayKit.Viewer.InstructionRequired", 0); to the OnEnable function. This is to hide the pop-up that appears after entering the map, as we will be proceeding directly to the instant navigation instead.

...
private void OnEnable()
{
    ContentStorageManager.OnReadyForARContentInitialize += LoadARContent;
    LocationpinViewController.OnLocationPinConfigured += LoadLocationpinContent;
+   PlayerPrefs.SetInt("ArwayKit.Viewer.InstructionRequired", 0);
}
... 

From there, if there is a matching value in the "notes" section of the Location Pin it will open the Location Pin Path Preview after the QR code is scanned, and the map content is loaded.

Example 2: Using the Anchor Description

Edit the Description of an Anchor to Include a Location Pin Name

In the Creator Portal Studio, select an Anchor, and then in the left menu, enter the following: InstantNav: locationPinName. We will use the "InstantNav:" portion as the identifier so that only if the keyword is present in the anchor that has been scanned, it will use the locationPinName to choose the instant navigation location pin. This means that you can replace "locationPinName" with the name of your location pin. Once you've added the description, click the "Save" button at the bottom, and then publish your map.

The location pin for instant navigation matches what has been set in the anchor description.

Modifying the SDK Code

In the file "Assets/ARway/ViewerMode/2_Scripts/SDK/ARMapLoader.cs" add the following function:

public void CheckForNavTo()
{
    string keyword = "InstantNav:";
    string lastQRCodeScanId = ArwayMapController.Instance.LastScanQRID();
    // Create a dictionary for faster lookup
    Dictionary<string, LocationPinUi> locationPinsWithID = ContentStorageManager.Instance.m_LocationPinsWithID;
    foreach (Anchor m_Anchor in ArwayMapController.MapData.data.metadata.anchors)
    {
        if (m_Anchor.id == lastQRCodeScanId && m_Anchor.description.StartsWith(keyword))
        {
            // Extract location pin name directly without using Substring
            string locationPinName = m_Anchor.description.Substring(keyword.Length).Trim();
            foreach (var kvp in locationPinsWithID)
            {
                LocationPinUi locationPinUi = kvp.Value;
                if (locationPinUi.locationPin.name == locationPinName)
                {
                    WindowManager.Instance.OpenPanel("LocationpinViewerPanel");
                    LocationpinViewer.Instance.OpenLocationDetails(locationPinUi);
                    LocationpinViewer.Instance.GetDirection();
                    return; // Exit loop if found
                }
            }
        }
    }
}

Then in that same file, add the following to line #5:

using System.Collections.Generic;

Then, on line #15, add the following line PlayerPrefs.SetInt("ArwayKit.Viewer.InstructionRequired", 0); to the OnEnable function. This is to hide the pop-up that appears after entering the map, as we will be proceeding directly to the instant navigation instead.

private void OnEnable()
{
    ContentStorageManager.OnReadyForARContentInitialize += LoadARContent;
    LocationpinViewController.OnLocationPinConfigured += LoadLocationpinContent;
+   PlayerPrefs.SetInt("ArwayKit.Viewer.InstructionRequired", 0);
}

Then at the bottom of the file, on line #139, add the line to the end of the LoadMapContent function, and the file will look like this:

...
    #region WayPointContent
    foreach (Waypoint3d tour in arContent.waypoints3ds)
    {
        ContentStorageManager.Instance.LoadNavigationTour(tour);
    }
    #endregion

    CheckForNavTo();
}

Then you can build your app. When you add the keywords to the anchor description in the Creator Portal Studio, you can enable the instant navigation functionality in your customized app.

Location Pin Advanced Settings
Adding the text InstantNav: locationPinName to the description of a QR code.
Location pin name matches the value in the QR code description.