[Huawei Developers] Freemind R:
More information like this, you can visit HUAWEI Developer Forum​

Introduction

Customers of Huawei maps are people who use maps API like Ecommerce, real estate portals, travel portals etc. and end users who use the Huawei maps application through different devices. End users also experience the maps interface through different search experiences like the local business searches, hotel searches, flight searches.

Let’s Start how to Integrate Map:

Step1: create a new project in Android studio.

Step 2: Configure your app into AGC.

Step 3: Enable required Api & add SHA-256.

Step 4: Download the agconnect-services.json from AGC. Paste into app directory.

Step 5: Add the below dependency in app.gradle file.

implementation 'com.huawei.hms:maps:4.0.0.301'
implementation 'com.huawei.hms:site:4.0.3.300'

Step 6: Add the below dependency in root.gradle file

maven { url 'http://developer.huawei.com/repo/' }

Step 7: Add appId & permissions in AndoridManifest.xml file

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<meta-data
android:name="com.huawei.hms.client.appid"
android:value="appid=*********" />

Step 8: Sync your Project

Use Cases:

Huawei site kit supports below capabilities.

· Keyword Search: It will display list based on user input.

· Nearby Place Search: It will display nearby places based on the current location of the user's device.

· Place Detail Search: Searches for details about a place.

· Place Search Suggestion: Returns a list of suggested places.

Let’s Discuss how to integrate Site Kit:

Declare SearchService create Instance for SearchService.

SearchService searchService = SearchServiceFactory.create(this,URLEncoder.encode("API_KEY", "utf-8"));

Create TextSearchRequest, which is the place to search request. below are the parameters.

query: search keyword.

location: longitude and latitude to which search results need to be biased.

radius: search radius, in meters. The value ranges from 1 to 50000. The default value is 50000.

poiType: POI type. The value range is the same as that of LocationType.

HwPoiType: Huawei POI type. his parameter is recommended. The value range is the same as that of HwLocationType.

countrycode: code of the country where places are searched. The country code must comply with the ISO 3166-1 alpha-2 standard.

language: language in which search results are displayed. For details about the value range, please refer to language codes in LanguageMapping

If this parameter is not passed, the language of the query field is used in priority. If the field language is unavailable, the local language will be used.

pageSize: number of records on each page. The value ranges from 1 to 20. The default value is 20.

pageIndex: current page number. The value ranges from 1 to 60. The default value is 1.

autoCompleteTextView.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

}

@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
if (timer != null) {
timer.cancel();
}
}

@Override
public void afterTextChanged(final Editable text) {
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
if (text.length() > 3) {
list.clear();
final TextSearchRequest textSearchRequest = new TextSearchRequest();
textSearchRequest.setQuery(text.toString());
searchService.textSearch(textSearchRequest, new SearchResultListener<TextSearchResponse>() {
@Override
public void onSearchResult(TextSearchResponse response) {
for (Site site : response.getSites()) {
LatLng latLng = new LatLng(site.getLocation().getLat(), site.getLocation().getLng());
SearchResult searchResult = new SearchResult(latLng, site.getAddress().getLocality(), site.getName());
String result = site.getName() + "," + site.getAddress().getSubAdminArea() + "\n" +
site.getAddress().getAdminArea() + "," +
site.getAddress().getLocality() + "\n" +
site.getAddress().getCountry() + "\n" +
site.getAddress().getPostalCode() + "\n";
list.add(result);
searchList.add(searchResult);
}
mAutoCompleteAdapter.clear();
mAutoCompleteAdapter.addAll(list);
mAutoCompleteAdapter.notifyDataSetChanged();
autoCompleteTextView.setAdapter(mAutoCompleteAdapter);
Toast.makeText(MainActivity.this, String.valueOf(response.getTotalCount()), Toast.LENGTH_SHORT).show();
}

@Override
public void onSearchError(SearchStatus searchStatus) {
Toast.makeText(MainActivity.this, searchStatus.getErrorCode(), Toast.LENGTH_SHORT).show();
}
});
}
}
}, 200);

autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
mAutoCompleteAdapter.getItem(position);
selectedPostion = searchList.get(position);
try {
createMarker(new LatLng(selectedPostion.latLng.latitude, selectedPostion.latLng.longitude));
} catch (IOException e) {
e.printStackTrace();
}

}
});
}
});

Output:

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/767/951/2640091000001767951.20200702110125.18879704559416751670057347036037:50510728022829:2800:0E2DB9F30BD9838AEDB7C20F1520795302B784B87E15BA4BF22BF230698FEA61.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/767/951/2640091000001767951.20200702110125.18879704559416751670057347036037:50510728022829:2800:0E2DB9F30BD9838AEDB7C20F1520795302B784B87E15BA4BF22BF230698FEA61.png[/IMG]

[IMG="https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/767/951/2640091000001767951.20200702110137.16165601088642293716303596208293:50510728022829:2800:A9C50EA5FD0FCC352AA7900F701332C1A0941514B68CE892FB7BA0CBADA9815A.png"]https://communityfile-dre.op.hicloud.com/FileServer/getFile/cmtybbs/001/767/951/2640091000001767951.20200702110137.16165601088642293716303596208293:50510728022829:2800:A9C50EA5FD0FCC352AA7900F701332C1A0941514B68CE892FB7BA0CBADA9815A.png[/IMG]​

Reference:

https://developer.huawei.com/consumer/en/doc/development/HMS-References/hms-map-cameraupdate

https://developer.huawei.com/consumer/en/doc/development/HMSCore-Guides/android-sdk-introduction-0000001050158571