Location APIs

openLocation

Open a map to display a specific location.

Overview

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.

Sample Code

<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>

Parameters

PropertyTypeRequiredDescription
longitudeStringYesLongitude of the location to display.
latitudeStringYesLatitude of the location to display.
nameStringNoName of the location.
addressStringNoDetailed address of the location.
scaleNumberNoZoom scale of the map, ranging from 3 to 19. Default is 15.
successFunctionNoCallback function upon call success.
failFunctionNoCallback function upon call failure.
completeFunctionNoCallback function upon call completion (to be executed upon either call success or failure).

Success Callback Function

The success callback is executed when the map is successfully opened.

Error Code

ErrorDescriptionSolution
11Invalid coordinates provided.Ensure longitude and latitude are valid values.
12Network abnormity, try again later.Prompt the user to check the current network.
13Failed to open map application.-

Usage Notes

  • Longitude and latitude are required parameters
  • The scale parameter controls the zoom level (3-19), with higher values showing more detail
  • Default zoom scale is 15 if not specified
  • The map application will open in a separate view
  • Providing a name and address helps users identify the location more easily