my.chooseLocation opens a map interface that allows users to choose a specific location. The selected location's details, including longitude, latitude, name, and address, are returned through the success callback.
my.chooseLocation({
success: (res) => {
console.log(res);
// Use the selected location data
const selectedLocation = {
name: res.name,
address: res.address,
latitude: res.latitude,
longitude: res.longitude
};
},
fail: (error) => {
my.alert({ title: 'Failed to choose location' });
},
});
| Property | Type | Required | Description |
|---|---|---|---|
success | Function | No | Callback function upon call success. |
fail | Function | No | Callback function upon call failure. |
complete | Function | No | Callback function upon call completion (to be executed upon either call success or failure). |
The incoming parameter is of the Object type with the following attributes:
| Property | Type | Description |
|---|---|---|
name | String | Name of the selected location. |
address | String | Detailed address of the selected location. |
latitude | Number | Latitude of the selected location. |
longitude | Number | Longitude of the selected location. |
| Error | Description | Solution |
|---|---|---|
11 | Location permission not enabled. | Prompt the user to enable location permission. |
12 | Network abnormity, try again later. | Prompt the user to check the current network. |
13 | User cancelled the selection. | - |