Integrating Map Kit Through HMS Toolkit

Erick Anthonius
5 min readMar 11, 2022

Hi everyone,

As a lightweight IDE tool plugin, HMS Toolkit implements app creation, coding, conversion, debugging, test, and release. It helps you integrate HMS Core APIs with lower costs and higher efficiency.

Configuration Wizard of HMS Toolkit enables you to automatically complete necessary configuration for development preparations.

Installing HMS Toolkit

Windows: Start Android Studio, go to File > Settings > Plugins > Marketplace, enter HMS Toolkit in the search box, and click Install. After the installation is complete, restart Android Studio.

macOS: Start Android Studio, go to Preferences > Plugins > Marketplace, enter HMS Toolkit in the search box, and click Install. After the installation is complete, restart Android Studio.

Configuring the Development Environment

Configuring App Information in AppGallery Connect

To develop an app, create it in AppGallery Connect and set required information.

  1. Use your HUAWEI ID to sign in to AppGallery Connect. If you do not have any HUAWEI ID, register one by referring to Registration and Verification.
  2. Create a project and create an app. Note that set Package type to APK (Android app).

Configuring the HMS Toolkit Environment

Before calling the Map Kit capabilities, perform the following steps to configure the environment:

  1. In Android Studio, go to HMS > Configuration Wizard.
  2. After sign-in authorization, select the team name, project module, integrated kit (Map Kit), and certificate type, click Generate to generate an SHA-256 certificate fingerprint, and click Next.

Click Generate to generate a certificate fingerprint. If the generation fails, check whether the certificate information matches the fingerprint. Alternatively, manually generate a fingerprint by referring to Generating a Signing Certificate Fingerprint and enter it in the text box.

Click Generate to generate a certificate fingerprint. If the generation fails, check whether the certificate information matches the fingerprint. Alternatively, manually generate a fingerprint by referring to Generating a Signing Certificate Fingerprint and enter it in the text box.

HMS Toolkit automatically checks the integration environment of Map Kit, including the general environment and the environment dedicated for the kit.

HMS Toolkit checks whether each configuration item is correct.

If an item fails to pass the check, as shown in the preceding figure, click Link to manually modify the item as prompted. You can also Check whether there is any app corresponding to your application’s package name in AppGallery Connect.

If all the items are passed, click Go to coding assistant to call APIs. For details, please refer to Kit Integration Wizard.

Integrating Map Kit Through Coding Assistant

Go to HMS > Coding Assistant, and select Map Kit in the kit list. The following figure shows all the scenarios of Map Kit.

Completing the Code by Dragging and Dropping Scenario Cards

Select a scenario card, for example, Map Creation, and drag and drop it to the code editing area to create a map.

When you drag and drop the scenario card, Toolkit automatically generates an Activity file and XML layout file, and writes the configurations and dependencies required for the project running to the AndroidManifest.xml file, project-level build.gradle file, and app-level build.gradle file. To open the Activity, you need to call the Activity in the code. After the Activity is called, you can run the app on the device.

Scenario Simulation Tool

Develop provides the device-cloud location data comparison service, distance calculation service, and route planning service.

  • Device-cloud location data comparison service: Compare the location data obtained on the device with that obtained on the cloud to analyze the location accuracy on the device.
  • Distance calculation service: Select the start and end locations to calculate the straight-line distance between them.
  • Route planning service: Select the start and end locations for the tool to automatically plan the route based on the set motion mode.

To use Develop, perform the following steps:

  1. On the toolbar of the Map Kit card, click Develop. The page is displayed.
  2. Select Data Comparison, Distance Calculation, or Path Planning.

Data Comparison:

a. Determine a location for simulation. The Develop tool provides two methods for entering location information:

Simulated position: Enter a location name.

Latitude and Longitude: Enter the longitude and latitude of a location.

After the location is determined, the tool automatically queries the location data stored in the cloud.

b. Obtain the location data on the device side.

Method of Obtaining Device-Side Data: Obtain the location data on the device side. You can choose Log scraping or Manual input. If you choose Log scraping, you need to run the project and click Start. A window is displayed, showing the location data list parsed from the logs. Select the required data and click Capture to capture the location data and inject the data to the comparison page, as shown in the following figure.

The cloud data is displayed in the left pane, and the device data is displayed in the right pane. Click Run to start device-cloud location data comparison. Orange indicates that the data on the left and right is different.

Distance Calculation: Enter information about the start and end locations (a location or longitude and latitude), and click Run to calculate the straight-line distance between the two locations.

Path Planning: Enter information about the start and end locations (a location or longitude and latitude), set Movement state, and click Run to plan the specific route

I hope you found this tutorial helpful and if you have any comments or questions, please let me know in the comments below.

--

--