Quick Run of the Example Project for the WeChat Mini Program Mega Plugin
This article will introduce how to quickly run the example project for the WeChat Mini Program Mega plugin. You will learn how to:
- Set up and configure the development environment for the example project.
- Run some functions of the example: Use Mega cloud localization.
Before You Start
- Refer to the documentation Is My Localization Function Ready to Use? to confirm that the localization library has been correctly created and the map has been added.
Confirm That the Mini Program Is of an Enterprise Type
Important
The Mega Mini Program plugin only supports WeChat Mini Programs of enterprise types. Mini Programs of individual types cannot use the Mega Mini Program plugin.
You need to confirm that in the Mini Program Backend, Settings > Basic Information > Entity Information shows Enterprise Legal Person or Individual Business Operator.
Since the Mega functions are provided in the form of a Mini Program plugin, you must have a WeChat Mini Program of an enterprise type as the host environment.
Even if you only want to run the example project we provided, you need to configure your own WeChat Mini Program AppID to conduct debugging and preview in the developer tools.
Download the Example Project
Go to the Development Tools Download Page.
Confirm the EasyAR Privacy Policy and then click to download.

After the download is completed, extract the
.zippackage locally.
Configure the Example Project
Log in to the WeChat Mini Program Developer Tools.
Import the sample project using the WeChat Mini Program Developer Tools.
- After opening the developer tools, click the import button and select the locally extracted directory.


- Ensure the AppID matches the AppID filled in when applying for the Mega license, and the development mode is Mini Program. Click create.
Note
Inconsistent AppID will cause license verification failure.

Configure mega license and cloud services
Open the file
miniprogram/components/sample-data/easyar-settings.tsand fill in the corresponding fields with the license and service information from the preparation work:- Mega License
/** Your mini program's mega license */ export const EasyARLicenseKey: string = "";How to obtain a mega WeChat mini program license
Select Mega WeChat Mini Program in the EasyAR Development Center.

The list should contain the Mega WeChat Mini Program License you want to use. (If no available license exists, verify if your account is the same as the one used to create the Mega positioning library).
Click the mini program name to obtain its Mega license (click the copy button on the right, then paste it into the
easyar-settings.tsfile as the value ofEasyARLicenseKey). Confirm that the associated AppID exactly matches your WeChat mini program AppID.
- Cloud service API key and secret
/** Your cloud service API key and secret */ export const EasyARAPIKey: string = ""; export const EasyARAPISecret: string = "";How to obtain cloud service API key and secret
Select Cloud Service API Key in the EasyAR Development Center.
If you have previously created cloud service API key and secret, copy them from the right side here and paste them into the
easyar-settings.tsfile as values forEasyARAPIKeyandEasyARAPISecret.
If you haven't created them before, create them as follows:
In the EasyAR Development Center, select Cloud Service API Key > Create API key.


Enter the application name, select the cloud services to use: Mega Block and/or Mega Landmark, then click OK.
- Cloud service server address and AppID:
/** Your mega cloud positioning library's server address and AppID */ export const MegaTrackerServerAddress: string = ""; export const MegaTrackerAppID: string = "";How to obtain the mega cloud positioning library's server address and AppID
Select Block Cloud Positioning in the EasyAR Development Center, then choose your Mega Cloud Positioning Service Group.

Select your mega cloud positioning library:


Click Key, then obtain the positioning library's AppID and Server Address below (click the copy button on the right, then paste them into the
easyar-settings.tsfile as values forMegaTrackerAppIDandMegaTrackerServerAddress).
Run the Example on a Real Device
Click the real-device preview button on the top bar of the Mini Program development tool, and load it onto your development phone by scanning the QR code.
Caution
You cannot directly simulate and run xr-frame components with AR functionality in the development tool.


Note
When you run the sample project in WeChat Developer Tools for the first time, if plugin permissions haven't been granted, the tool typically prompts that the plugin is unauthorized. You can authorize automatically via WeChat Developer Tools or refer to the Plugin access process.
Click EasyAR Mega Samples to enter the AR scene of the sample project.

Note
If you cannot enter the AR scene of the sample project, it may be because the current device does not support WeChat's VisionKit visual algorithm component. For details, refer to Device limitations.
The on-screen prompt
EasyAR Session is initializingindicates WeChat plane detection is initializing.Tip
Ensure testing in well-lit environments, avoiding large areas of solid-color walls or floors.
Swing steadily left and right facing the ground or other planes to speed up this process.

After initialization is complete, hold the phone vertically to capture a normal real-world view with the camera. When positioning succeeds, the word
Foundappears in debug information, and the status indicator in the lower-right corner changes from white to green.