Using the Mega Landmark Service
This article introduces how to use the Mega Landmark positioning service after integrating the Mega plugin in a WeChat Mini Program.
Before you begin
- Obtain and use an APIKey (must include Mega Landmark).
- Understand the concepts and workflow of MegaTracker.
- Understand MegaTracker cloud service authentication.
Enable Mega Landmark
First, create a MegaTrackerConfigs using Landmark as the apiType.
Then, create a SessionConfigs using the MegaTrackerConfigs and the licenseKey from the configuration.
Finally, create a session using the createSession(sessionConfigs) method of the EasyARMegaComponent attached to 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 a MegaLandmarkFilter internally.
Its function is to filter the most suitable Mega positioning database for the current context via 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 positioning status remains MissingSpotVersionId.
- Match the positioning database using the provided SpotID:
Use the filterBySpotId(spotId) method of Landmark to match the positioning database via 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 the positioning database using current GNSS data:
Use the filterByLocation() method of Landmark to match the positioning 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}`)
}
}