my.openLocation opens the map application to display a specific location using the provided longitude and latitude coordinates. You can also specify the location name, address, and zoom scale.
<script>
function openLocation() {
AlipayJSBridge.call('openLocation', {
longitude: '44.367331',
latitude: '33.313738',
name: 'Al Kindi',
address: 'Baghdad, Baghdad Governorate',
}, function (res) {
alert('AlipayJSBridge openLocation result:\n' + JSON.stringify(res));
});
}
</script>
| Property | Type | Required | Description |
|---|---|---|---|
longitude | String | Yes | Longitude of the location to display. |
latitude | String | Yes | Latitude of the location to display. |
name | String | No | Name of the location. |
address | String | No | Detailed address of the location. |
scale | Number | No | Zoom scale of the map, ranging from 3 to 19. Default is 15. |
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 success callback is executed when the map is successfully opened.
| Error | Description | Solution |
|---|---|---|
11 | Invalid coordinates provided. | Ensure longitude and latitude are valid values. |
12 | Network abnormity, try again later. | Prompt the user to check the current network. |
13 | Failed to open map application. | - |
scale parameter controls the zoom level (3-19), with higher values showing more detail