Parameters
Success Callback
Error Codes
Code Example
Related APIs
my.openLocation
Open location in map
my.chooseLocation
Choose a location
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Get the current geographic location.
| Property | Type | Required | Description |
|---|---|---|---|
| type | Number | No | 0: default, get the longitude and latitude |
| cacheTimeout | Number | No | Longitude and latitude location cache expiry time in seconds. Default is 30s |
| success | Function | No | Callback with location |
| fail | Function | No | Callback on failure |
| complete | Function | No | Callback that always executes |
| Property | Type | Description |
|---|---|---|
| longitude | String | Longitude |
| latitude | String | Latitude |
| accuracy | String | Accuracy, in m |
| Error | Description | Solution |
|---|---|---|
| 11 | Make sure the location related right has been enabled | Prompt the user to enable location permission |
| 12 | Network abnormity, try again later | Prompt the user to check the current network |
| 13 | Location failure, try again later | — |
| 14 | Service location timeout | Prompt the user to try again |
my.getLocation({
success: (res) => {
console.log('Lat:', res.latitude);
console.log('Lng:', res.longitude);
}
});