Table of Contents

Usare il servizio Mega Landmark

Questo articolo descrive come usare il servizio di localizzazione Mega Landmark dopo l'integrazione del plugin Mega per WeChat Mini Program.

Prima di iniziare

Abilitare Mega Landmark

Per prima cosa, usa Landmark come apiType per creare MegaTrackerConfigs.

Poi usa MegaTrackerConfigs e il licenseKey nella configurazione per creare SessionConfigs.

Infine, usa il metodo createSession(sessionConfigs) di EasyARMegaComponent montato nella scena xr-frame per creare session.

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

Come usare LandmarkFilter

Quando viene creato usando Landmark, MegaTracker istanzia automaticamente internamente MegaLandmarkFilter.

La sua funzione è permettere a MegaTracker di filtrare la libreria di mappe di localizzazione Mega più adatta tramite SpotId o dati GNSS quando usa il servizio Landmark.

Le API di filtro possono essere chiamate solo dopo che start(options) ha avuto esito positivo.

Quando MegaTracker usa il servizio Landmark e il filtro non è riuscito, lo stato di localizzazione è sempre MissingSpotVersionId

  • Usare lo SpotID fornito per abbinare la libreria di mappe di localizzazione:

Usa il metodo filterBySpotId(spotId) di Landmark per abbinare la libreria di mappe di localizzazione tramite 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}`)
    }
}
  • Usare i dati GNSS correnti per abbinare la libreria di mappe di localizzazione:

Usa il metodo filterByLocation() di Landmark per abbinare la libreria di mappe di localizzazione usando i dati GNSS correnti:

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}`)
    }
}