Cordova HMS Map Plugin | Installation and Example - Huawei Developers

Introduction
In this article, I will explain what Cordova HMS Map Kit is, how to integrate it to the cordova base project and usage of it.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Huawei Map Kit enables communication between HUAWEI Map Kit SDK and Cordova platform. It exposes all functionality provided by HUAWEI Map Kit SDK.
Prerequisites
Before installing Map Kit, you should have installed npm, Node.js and Cordova CLI.
Installation
Let’s start with creating a cordova project. Open Window CMD and create a cordova project like below.
Code:
<p style="line-height: 1.5em;"># create a cordova based project. You can change name of the project as whatever you want.
$ cordova create HMSMapDemo com.hms.mapdemo HmsMap</p>
This command will create a directory called HMSMapDemo where our cordova project is.
After this command, you should add platform to the project. To add, follow command below:
Code:
<p style="line-height: 1.5em;"># first go into cordova project directory
$ cd HMSMapDemo
# add android platform
$ cordova platform add android</p>
Next, add the cordova-plugin-hms-map plugin to your project.
Run the following command in the root directory of your Cordova project to install it through npm.
Code:
<p style="line-height: 1.5em;">$ cordova plugin add @hmscore/cordova-plugin-hms-map</p>
To you use HMSMap plugin, you should have agconnect-services.json and .jks files. Following this guide, you can configure all requirements to use HMS Map Plugin.
After configuration step, finally build project with command below:
Code:
<p style="line-height: 1.5em;">$ cordova build android
</p>
After that, open your android studio project and you are ready to use plugin.
Using Cordova HMS Map Plugin
This section describes how to use the plugin to quickly obtain a map object, change the map type, display my-location on the map, and enable the map’s lite mode.
Creating Map Object
Every map object is bound to a div element in html file. Let’s create a div element in html and change value of id property as “map”.

How can we draw dotted polyline?

that's a nice start...

Mais ficar incrível esse mapa quando tiver completo.

Related

HUAWEI Drive Kit Development Process (Part*2)

More information like this, you can visit HUAWEI Developer Forum
​
SDK Description
To integrate HUAWEI Drive Kit into your app, you will need to integrate both the HMS SDK and the Drive SDK. The HMS SDK provides sign-in and authentication information, while the Drive SDK provides the capability of managing users' files in Drive.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Integrating the Drive SDK and HMS SDK
If you are using Android Studio, you can integrate your Drive SDK and HMS SDK by using the Maven repository. Before you start developing an app, integrate both the Drive SDK and HMS SDK into your Android Studio first.
1. Add the AppGallery Connect configuration file of the app to your Android Studio.
a. Sign in to AppGallery Connect and select My projects.
b. Find your project from the project list and click the app on the project card.
c. On the Project Setting page, click agconnect-services.json to download the configuration file.
d. Copy the agconnect-services.json file to the app root directory.
2. Configure the Maven repository address for the HMS SDK.
a. Open the build.gradle file in the root directory of your Android Studio project.
3. Add build dependencies.
a. Open the build.gradle file in the app directory.
5. Define multi-language settings.
By default, your app supports all languages provided by the HMS SDK.If your app uses all these languages, skip the operation procedure in this section.
If your app uses only some of these languages, follow the operation procedure in this section to complete the required configuration.
Open the build.gradle file in the app directory of your project.
Go to android > defaultConfig and add the resConfigs configuration. en (English) and zh-rCN (Simplified Chinese) are mandatory languages. If your app only supports English and Simplified Chinese, the configuration is as follows:

Integrating Ads kit using Flutter (Hybrid development)

Introduction
Huawei is providing one of the best HMS Ads kit to advertise their ads via mobile apps. In this way they can reach their target audience more easily and they can measure their efficiency. Using Ads kit we can create high quality and personalized ads in our application.
        
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Supported Ad Types
1. Splash Ads
2. Banner Ads
3. Interstitial Ads
4. Native Ads
5. Rewarded Ads
6. Roll Ads
7. Express Splash Ads
Flutter setup
 Refer this URL to setup Flutter.
Software Requirements
 1. Android Studio 3.X
2. JDK 1.8 and later
3. SDK Platform 19 and later
4. Gradle 4.6 and later
Steps to integrate service
1. Register as a Developer
2.Create an App
3.Enable required services (Cloud or Device)
4.Integrate HMS Core SDK
5.Apply for SDK Permission
6.Perform App Development
7.Perform pre-release check (Mandatory)
Development Process
Create Application in Android Studio.
1. Create Flutter project.
2. App level gradle dependencies. Choose inside project Android > app > build.gradle
Code:
apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
Gradle dependencies
Code:
implementation 'com.huawei.hms:ads-lite:13.4.34.301'
implementation 'com.huawei.hms:ads-consent:3.4.34.301'
implementation 'com.huawei.hms:ads-identifier:3.4.32.300'
implementation 'com.huawei.hms:ads-installreferrer:3.4.32.300'
Root level gradle dependencies
Code:
maven {url 'https://developer.huawei.com/repo/'}
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
Add the below permissions in Android Manifest file.
Code:
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.INTERNET" />
<application>
</manifest>
3. Add agconnect-services.json into under app directory.
4. Add HMS Ads kit plugin download using below URL.
https://developer.huawei.com/consum...y-V1/flutter-sdk-download-0000001050196675-V1
5. Add downloaded file into outside project directory. Declare plugin path in pubspec.yaml file under dependencies.
Code:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
huawei_ads:
path: ../huawei_ads/
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- assets/1.png
- assets/3.png
- assets/5.png
- assets/2.png
- assets/7.png
6. After adding all required plugins click Pub get, automatically it will install latest dependencies.
7. We can check the plugins under External Libraries directory.
8. Open main.dart file to create UI and business logics.
More detials, you can check https://forums.developer.huawei.com/forumPortal/en/topic/0203423861622320018

How Can I Integrate Remote Configuration of AppGallery Connect in Cordova?

Recently, it is found that AppGallery Connect Remote Configuration starts to support Cordova. The integration is rather simple, let’s have a try.If you want to quickly experience this service, see the demo on GitHub.
Integration Procedure
1. Create a project directory on your computer, run the following npm command to install Cordova.
npm install -g cordova
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
2. Create a project and enable Remote Configuration.
a) Create an Android app in AppGallery, add it to a project, enable Remote Configuration, and add a parameter.
b) Run the following command to create a Cordova project. In this example, name the project RemoteConfig.
cordova create RemoteDemo com.huawei.cordova.remoteconfig RemoteConfig Creating a new cordova project.
c) Add an app platform to the project.
In the project directory, run cordova platform add android to add the Android platform.
Run cordova platform -l to view the supported platforms.
d) Go to Project settings in AppGallery Connect, download the agconnect-services.json file, and add the file to the android/app directory of your project.
e) Install the AppGallery Connect plug-in.
cordova plugin add @Cordova-plugin-agconnect/remoteconfig --save
After the plug-in is installed, you can view it in the plugins directory.
Add the AppGallery Connect plug-in address to app/build.gradle.
3. Use the Remote Configuration service.
1. Fetch data from the cloud. The data takes effect this time.
Call the fetch API to fetch parameter values from the cloud, and call the apply API to make them take effect.
You can view the fetched parameter values on the cloud in log information.
The other values displayed in log information are local ones.
2. Fetch the cloud data and make the parameter values fetched last time take effect.
Replace the fetch API with applyLastFetch to fetch data that is fetched from the cloud last time.
3. Clear the data.
Call the clearAll API to clear the cached data that is fetched earlier.
4. Fetch the value of a key from the cloud.
Call getValue to fetch related data from the cloud.
4. Compile and install an app package.
Run the cordova build android command to compile the project.
Find the APK package in the build folder in the android directory.
For more details, please check:
Cordova documentation:
https://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html
Remote Configuration API Reference:
https://github.com/AppGalleryConnect/agc-demos/tree/main/Cordova/agc-remoteconfig-cordova
Remote Configuration Demo:
https://github.com/AppGalleryConnect/agc-demos/tree/main/Cordova/agc-remoteconfig-cordova

Integrating AR-Engine kit using Flutter (Cross Platform)

Introduction
Augmented Reality is increasing every day in different areas like shopping, Games, Education etc. AR Engine provides a mesh with more than 4,000 vertices and 7,000 triangles to precisely outline face contours, and enhance the overall user experience.
Today I will develop a demo application and try to explain this features and what it provides in more detail.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
AR Engine Services
Augmented reality (AR) is an interactive experience of a real-world environment where the objects reside in the real world are enhanced by computer-generated perceptual information, sometimes across multiple sensory modalities, including visual, auditory, haptic, somatosensory and olfactory.
It provide basic AR capabilities such as motion tracking, environment tracking, body tracking, and face tracking.
Restrictions
The current version of Huawei AR Engine supports only Huawei devices. So, you need a Huawei phone that supports Huawei AR Engine, you can see the supported devices below.
AR Engine Process
The following figure shows the general process of using the Huawei AR Engine SDK.
        
Flutter setup
Refer this URL to setup Flutter.
Software Requirements
1. Android Studio 3.X
2. JDK 1.8 and later
3. SDK Platform 24 and later
4. Gradle 4.6 and later
5. Ensure that the AR Engine server APK have been downloaded from AppGallery and installed on the device. To do so, search for HUAWEI AR Engine in Huawei AppGallery.
            
Steps to integrate service
1. We need to register as a developer account in AppGallery Connect
2. Create an app by referring to Creating a Project and Creating an App in the Project
3. Set the data storage location based on current location
4. Generating a Signing Certificate Fingerprint.
5. Configuring the Signing Certificate Fingerprint.
6. Get your agconnect-services.json file to the app root directory.
Development Process
Create Application in Android Studio.
1. Create Flutter project.
2. App level gradle dependencies. Choose inside project Android > app > build.gradle.
Code:
apply plugin: 'com.android.application'
apply plugin: 'com.huawei.agconnect'
Root level gradle dependencies
Code:
maven {url 'https://developer.huawei.com/repo/'}
classpath 'com.huawei.agconnect:agcp:1.4.1.300'
Add the below permissions in Android Manifest file.
Code:
<manifest xlmns:android...>
...
<uses-permission android:name="android.permission.CAMERA" />
<application ...
</manifest>
3. Add HMS AR Engine kit plugin download using below URL.
https://developer.huawei.com/consum...y-V1/flutter-sdk-download-0000001059096444-V1
4. On your Flutter project directory find and open your pubspec.yaml file and add library to dependencies to download the package from pub.dev. Or if you downloaded the package from the HUAWEI Developer website, specify the library path on your local device. For both ways, after running pub get command, the plugin will be ready to use.
Code:
name: arDemo
description: A new Flutter application.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
huawei_ar:
path: ../huawei_ar/
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
5. We can check the plugins under External Libraries directory.
6. Open main.dart file to create UI and business logics.
More details, you can check https://forums.developer.huawei.com/forumPortal/en/topic/0202460753111420009

Integrating Cloud Functions in a Flutter application

Cloud Functions enables serverless computing through Function as a Service (FaaS) capabilities to simplify app development and O&M. This helps you implement functions more simply and build service capabilities more quickly. The following describes how to integrate Huawei’s AppGallery Connect Cloud Function service in Flutter.
We will create a basic new project as an example but of course, you could make use of a project you already have that's using flutter!
Project Setup​Install the Flutter environment.​Download the Flutter SDK package and decompress the package to any directory.
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Download the Flutter and Dart plugins in Android Studio.
Enable Huawei Cloud Functions​Create an Android app in AppGallery Connect and enable Cloud Functions for it as detailed in this guide.
Now we can go ahead and create a cloud function as you require it to use this guide to help understand what can be done.
Once you are happy with your function (in this instance it might just be as simple as returning a hello world statement for testing) you can go ahead and create a HTTP trigger that will trigger the function.
Create Flutter Project​Next create your flutter project in android studio (or open your existing project if you already have one!).
Download your agconnect-services.json file from the AppGallery Connect console and add it to your project under the ‘app’ directory
Within the project-level build.gradle file make sure to include the Huawei maven repo and add the agcp package as a dependency.
Code:
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath 'com.huawei.agconnect:agcp:1.6.2.300'
}
}
Next in your app level build.gradle apply the agconnect plugin as so:
Code:
apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
apply plugin: 'com.huawei.agconnect'
Then in your pubspec.yaml file add the Cloud Function SDK dependency.
Code:
dependencies:
flutter:
sdk: flutter
agconnect_cloudfunctions: 1.2.0+300
Call the Cloud function​The below code is an example of how you can call a simple cloud function and get the result returned.
Code:
FunctionCallable functionCallable = FunctionCallable("test-\$latest");
Map<String, dynamic> parameters = <String, dynamic>{
'year': _functionTextController.text
};
FunctionResult functionResult = await functionCallable.call(parameters);
Where test-\$latest is the HTTP trigger identifier.
https://devwithzachary.medium.com/?...-------------------post_sidebar--------------
Good Article
Thanks for sharing!!!
Do we need any special permission for cloud function.
Thanks for sharing!

Categories

Resources