Huawei Map Kit is used for displaying the map and interaction with it. We can display schools, buildings, roads restaurants on map and also add marker, polygon and various shapes on it. It also provides interaction with gesture and buttons.
This article explains about showing the map, user location, adding and removing.
Let us start with the project configuration part:
Step 1: Create an app on App Gallery Connect.
Step 2: Enable the Map Kit in Manage APIs menu.
Step 3: Create new Xamarin (Android) project.
Step 4: Change your app package name same as AppGallery app’s package name.
a) Right click on your app in Solution Explorer and select properties.
b) Select Android Manifest on left side menu.
c) Change your Package name as shown in below image.
Step 5: Generate SHA 256 key.
a) Select Build Type as Release.
b) Right click on your app in Solution Explorer and select Archive.
c) If Archive is successful, click on Distribute button as shown in below image.
d) Select Ad Hoc.
e) Click Add Icon.
f) Enter the details in Create Android Keystore and click on Create button.
g) Double click on your created keystore and you will get your SHA 256 key. Save it.
f) Add the SHA 256 key to App Gallery.
Step 6: Sign the .APK file using the keystore for Release configuration.
a) Right-click on your app in Solution Explorer and select properties.
b) Select Android Packaging Signing and add the Keystore file path and enter details as shown in image.
Step 7: Install Huawei Map NuGet Package.
Step 8. Integrate HMS Core SDK.
Step 9: Add SDK Permissions.
Let us start with the implementation part:
Step 1: Create the xml layout for showing the map view.
Step 2: Define runtime permission inside activity’s OnCreate() method.
Step 3: Create MainActivity.cs which is showing the map, user location, adding and removing the marker.
Tips and Tricks
Please add map meta-data inside application tag of manifest file.
In this article, we have learnt to show the map with user current location. Also learnt to adding and removing the marker with map view.
Thanks for reading! If you enjoyed this story, please provide Likes and Comments.