This module provides the function of obtaining an offline map.
Since: 26.0.0
getRecommendedCityIdsByLatLngs(context: common.Context, latlngs: mapCommon.LatLng[]): Promise<string[]>
Queries undownloaded offline map regions on the device based on the longitude and latitude array. This API uses a promise to return the result.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.Map.Core.OfflineMapData
Since: 26.0.0
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| context | common.Context | Yes | Context. |
| latlngs | mapCommon.LatLng[] | Yes | Longitude and latitude array, with a maximum length of 20. If an invalid value is passed, an empty array [] is returned. |
Returns:
| Type | Description |
|---|---|
| Promise<string[]> | Promise used to return the recommended region list array. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
| ID | Error Message |
|---|---|
| 1002600001 | System internal error. |
| 1002600004 | The Map permission is not enabled. |
Example:
// Longitude and latitude array.
let latLngArr: mapCommon.LatLng[] = [
{ latitude: 49.5, longitude: 3.5 },
{ latitude: 49.5, longitude: 4.5 },
{ latitude: 50.5, longitude: 4.5 },
{ latitude: 51.5, longitude: 4.5 }];
let resArray: string[] = await offlineMapData.getRecommendedCityIdsByLatLngs(this.getUIContext().getHostContext(), latLngArr);