Links
Comment on page

Instant Location Pin Navigation

Immediately open the location pin navigation preview after scanning the QR code
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("View Location Pin Panel");
LocationPinViewHandler.Instance.OpenLocationDetails((LocationPinItem)locationPin);
LocationPinViewHandler.Instance.OpenLocationPathInMinimap();
We use the existing WindowManager and LocationPinViewHandler to open the panels required for the path preview.

Triggering Location Pin Path Preview through QR Code Scan: An Example

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.
Location Pin Advanced Settings

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/ARwayKitSDK/SampleApp/2_Scripts/ARMapLoader.cs" add the following function:
public void CheckForNavTo()
{
if (arContent.destination3ds.Count == 0 || !PlayerPrefs.HasKey("NavToValue"))
{
return;
}
string navToValue = PlayerPrefs.GetString("NavToValue");
PlayerPrefs.DeleteKey("NavToValue");
PlayerPrefs.Save();
foreach (LocationPinItem locationPin in LocationPinViewHandler.Instance.m_locationItems)
{
string note = locationPin.locationPin?.advanced?.note;
if (!string.IsNullOrEmpty(note) && note == navToValue)
{
WindowManager.Instance.OpenPanel("View Location Pin Panel");
LocationPinViewHandler.Instance.OpenLocationDetails(locationPin);
LocationPinViewHandler.Instance.OpenLocationPathInMinimap();
}
}
}
Then, include the function call at the end of LoadMapContent, around line 105.
...
#region LocationPinContent
foreach (Destination3d locationPin in arContent.destination3ds)
{
ContentStorageManager.Instance.LoadDestinationPinData(locationPin);
}
ContentStorageManager.Instance.LoadLocationPinView();
#endregion
+ CheckForNavTo();
}
...
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.