English
getLocation
About 177 wordsLess than 1 minute
2025-12-16
Adapter for location capability
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| opts | Object | Yes | Configuration options object |
| opts.onSuccess | Function | Yes | Success callback function |
| opts.onFail | Function | Yes | Failure callback function |
Return Value
No return value. Results are returned through callback functions.
Success Callback Parameters (onSuccess)
| Parameter Name | Type | Description |
|---|---|---|
| errorCode | Number | Error code, 0 indicates success |
| success | Boolean | Whether the operation succeeded |
| address | String | Detailed address information |
| title | String | Location title, currently an empty string |
| longitude | Number | Longitude |
| latitude | Number | Latitude |
| country | String | Country, currently an empty string |
| province | String | Province, currently an empty string |
| city | String | City, currently an empty string |
| district | String | District / county, currently an empty string |
Failure Callback Parameters (onFail)
| Parameter Name | Type | Description |
|---|---|---|
| error | String | Error message |
Usage Example
getLocation(opts) {
jsBridge.invokie('getLocation', {
onSuccess(res){
// Successfully called the native location interface of the third-party app
opts.onSuccess({
errorCode: 0,
success: true,
address: res.address,
title: '',
longitude: res.long,
latitude: res.lant,
country: '',
province: '',
city: '',
district: ''
});
},
onFail() {
opts.onFail('Call failed');
}
})
}Native bridge interface provided by the third-party app.
