Expert: Integration of Android Google Map and Huawei Map
HMS Core Map SDK is a set of APIs for map development in Android. The map data covers most countries outside China and supports multiple languages. The Map SDK uses the WGS 84 GPS coordinate system, which can meet most requirements of map development outside China.
Overview
In this article, I will create an Android Demo app which highlights integration of Google Map and Huawei Map in Single Android App.
I will create an AppGallery project and will deploy AppGallery into the application.
Huawei Map Introduction
HMS Core Map SDK is a set of APIs for map development in Android. The map data covers most countries outside China and supports multiple languages. The Map SDK uses the WGS 84 GPS coordinate system, which can meet most requirements of map development outside China. You can easily add map-related functions in your Android app, including:
1. Map display: Displays buildings, roads, water systems, and Points of Interest (POIs).
2. Map interaction: Controls the interaction gestures and buttons on the map.
3. Map drawing: Adds location markers, map layers, overlays, and various shapes.
Google Map Introduction
Google Map SDK for Android, add maps to your Android app including Wear OS apps using Google Maps data, map displays, and map gesture responses. You can also provide additional information for map locations and support user interaction by adding markers, polygons, and overlays to your map.
Prerequisite
1. Huawei Phone
2. Android Studio
3. Google Firebase Account
4. AppGallery Account
App Gallery Integration process
1. Sign In and Create or Choose a project on AppGallery Connect portal.
2. Navigate to Project settings and download the configuration file.
3. Navigate to General Information, and then provide Data Storage location.
4. Navigate to Manage APIs and enable APIs which is required by application.
Google Integration Process
1. Choose Map SDK.
2. Enable APIs and choose API for integration.
3. Create Credentials and get Your API Key.
4. APIs & Services.
App Development
1. Create A New Project.
2. Configure Project Gradle.
3. Configure App Gradle.
4. Configure AndroidManifest.
5. Create Activity class with XML UI.
MainActivity.java:
This activity performs all the operation of selection of Google map and Huawei map.
main_activity.xml:
HuaweiMapActivity:
This activity performs Huawei map integration and display Huawei map.
Huawei_map_activity.xml
GoogleMapActivity:
This activity performs Google map integration and display Google map.
google_map_activity.xml
App Build Result
Tips and Tricks
1. The logs contain “responseBody is returnCode: 010010; resultInfo: unkown error.” and “MapClientDataImpl.getAppId()”. The cause is that the app ID fails to be obtained. You can add under application in the AndroidManifest.xml file.
2. Map Kit needs to read appid and other attributes from the AppGallery Connect configuration file. In some conditions, Map Kit can’t read appid.
Conclusion
In this article, we have learned how to integrate Google Map and Huawei Map in application. In this application, I have explained the basic map and shown the similarity and differences.
Thanks for reading this article. Be sure to like and comments to this article, if you found it helpful. It means a lot to me.
References
Huawei Map Doc
Google Map Docs
https://developers.google.com/maps/documentation/android-sdk/start