Table of Contents

Use Mega Landmark service

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

Before you start

Enable Mega Landmark

First, use Landmark as apiType to create MegaTrackerConfigs.

Then use MegaTrackerConfigs and the licenseKey in the configuration to create SessionConfigs.

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

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 using Landmark, MegaTracker automatically instantiates MegaLandmarkFilter internally.

Its function is to let MegaTracker filter the most suitable Mega localization map library by SpotId or GNSS data when using the Landmark service.

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

When MegaTracker uses the Landmark service and filtering has not succeeded, the localization status is always MissingSpotVersionId

  • Use the provided SpotID to match the localization map library:

Use the filterBySpotId(spotId) method of Landmark to match the localization map library by 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}`)
    }
}
  • Use the current GNSS data to match the localization map library:

Use the filterByLocation() method of Landmark to match the localization map library by using the 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}`)
    }
}