LatLngBounds utility class.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since version 4.1.0(11).
System capability: SystemCapability.Map.Core
Since: 4.1.0(11)
static contains(bounds: mapCommon.LatLngBounds, position: mapCommon.LatLng): boolean
Checks whether a LatLngBounds object contains specified location coordinates.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since version 4.1.0(11).
System capability: SystemCapability.Map.Core
Since: 4.1.0(11)
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| bounds | mapCommon.LatLngBounds | Yes | LatLngBounds object. |
| position | mapCommon.LatLng | Yes | Location coordinates. |
Returns:
| Type | Description |
|---|---|
| boolean | true: The LatLngBounds object contains the location (including coordinate points lying on the LatLngBounds boundary). false: The LatLngBounds object does not contain the location. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
| ID | Error Message |
|---|---|
| 401 | Invalid input parameter. |
Example:
let bounds: mapCommon.LatLngBounds = {
southwest: {
latitude: 31.98,
longitude: 118.766
},
northeast: {
latitude: 32.08,
longitude: 118.066
}
};
let result: boolean = map.LatLngBoundsUtils.contains(bounds, {
latitude: 15,
longitude: 15
}); static contains(src: mapCommon.LatLngBounds, target: mapCommon.LatLngBounds): boolean
Checks whether a LatLngBounds object contains the destination region.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since version 4.1.0(11).
System capability: SystemCapability.Map.Core
Since: 4.1.0(11)
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| src | mapCommon.LatLngBounds | Yes | LatLngBounds object. |
| target | mapCommon.LatLngBounds | Yes | Destination region. |
Returns:
| Type | Description |
|---|---|
| boolean | true: The LatLngBounds object contains the destination region. false: The LatLngBounds object does not contain the destination region. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
| ID | Error Message |
|---|---|
| 401 | Invalid input parameter. |
Example:
let src: mapCommon.LatLngBounds = {
southwest: {
latitude: 31.98,
longitude: 118
},
northeast: {
latitude: 31.08,
longitude: 119
}
};
let target: mapCommon.LatLngBounds = {
southwest: {
latitude: 33,
longitude: 120
},
northeast: {
latitude: 34,
longitude: 121
}
};
let result: boolean = map.LatLngBoundsUtils.contains(src, target); static getCenter(bounds: mapCommon.LatLngBounds): mapCommon.LatLng
Obtains the longitude-latitude coordinates of the center of a LatLngBounds object.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since version 4.1.0(11).
System capability: SystemCapability.Map.Core
Since: 4.1.0(11)
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| bounds | mapCommon.LatLngBounds | Yes | LatLngBounds object. |
Returns:
| Type | Description |
|---|---|
| mapCommon.LatLng | Longitude-latitude coordinates of the center. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
| ID | Error Message |
|---|---|
| 401 | Invalid input parameter. |
Example:
let bounds: mapCommon.LatLngBounds = {
southwest: {
latitude: 31,
longitude: 118
},
northeast: {
latitude: 33,
longitude: 119
}
};
let center: mapCommon.LatLng = map.LatLngBoundsUtils.getCenter(bounds); static include(position: mapCommon.LatLng, bounds?: mapCommon.LatLngBounds): mapCommon.LatLngBounds
Obtains a LatLngBounds object that contains a specified location.
Model restriction: This API can be used only in the stage model.
Atomic service API: This API can be used in atomic services since version 4.1.0(11).
System capability: SystemCapability.Map.Core
Since: 4.1.0(11)
Parameters:
| Name | Type | Mandatory | Description |
|---|---|---|---|
| position | mapCommon.LatLng | Yes | Location coordinates. |
| bounds | mapCommon.LatLngBounds | No | LatLngBounds object. If this parameter is left empty, the created LatLngBounds object contains only the location coordinates. |
Returns:
| Type | Description |
|---|---|
| mapCommon.LatLngBounds | LatLngBounds object that contains the specified location. |
Error codes:
For details about the error codes, please refer to ArkTS API Error Codes.
| ID | Error Message |
|---|---|
| 401 | Invalid input parameter. |
Example:
let resultBounds: mapCommon.LatLngBounds = map.LatLngBoundsUtils.include({
latitude: 31,
longitude: 118
});