Table of Contents

Using Mega Landmark service

This article introduces how to use the localization service of Mega Landmark after integrating the Mega plugin in WeChat Mini Program.

Before you begin

Enable Mega Landmark

First create MegaTrackerConfigs using Landmark as apiType.

Then create SessionConfigs using MegaTrackerConfigs and licenseKey from configuration.

Finally, create the session using the createSession(sessionConfigs) method of the EasyARMegaComponent mounted in the xr-frame scene.

const megaTrackerConfigs: easyar.MegaTrackerConfigs = {
    access: apiKeyAccess,
    apiType: mega.MegaApiType.Landmark
};
const sessionConfigs: easyar.SessionConfigs = {
    megaTrackerConfigs: megaTrackerConfigs,
    licenseKey: settings.EasyARLicenseKey
};
session = megaComponent.createSession(sessionConfigs);

How to use LandmarkFilter

When created with Landmark, MegaTracker automatically instantiates MegaLandmarkFilter internally.

Its function is to filter the most suitable Mega localization database through SpotId or GNSS data when MegaTracker uses the Landmark service.

The filtering interface can only be called after start(options) succeeds.

When MegaTracker uses the Landmark service but fails to filter successfully, the localization status remains MissingSpotVersionId

  • Match localization database using provided SpotID:

Use the filterBySpotId(spotId) method of Landmark to match the localization database through SpotID:

async landmarkFilter() {
    const res = await session.megaTracker.landmarkFilter.filterBySpotId(settings.LandmarkSpotId);
    if (res.status != mega.MegaLandmarkFilterStatus.Found) {
        console.error(`LandmarkFilter Failed, status: ${mega.MegaLandmarkFilterStatus[res.status]}, exceptionInfo : ${res.exceptionInfo}`)
    }
}
  • Match localization database using current GNSS data:

Use the filterByLocation() method of Landmark to match the localization database using current GNSS data:

async landmarkFilter() {
    const res = await session.megaTracker.landmarkFilter.filterByLocation();
    if (res.status != mega.MegaLandmarkFilterStatus.Found) {
        console.error(`LandmarkFilter Failed, status: ${mega.MegaLandmarkFilterStatus[res.status]}, exceptionInfo : ${res.exceptionInfo}`)
    }
}