my.openLocation

View the location on the built-in map.

Supported types of mini programs: DSL, H5, H5+

Sample code

DSL

copy
my.openLocation({
  longitude: '120.126293',
  latitude: '30.274653',
  name: 'Huanglong Vanke Center...',
  address: '77 xueyuan road',
  success: res => {
    console.log('openLocation Success:', JSON.stringify(res, null, 2))
  },
  fail: res => {
    console.log('openLocation Failed:', JSON.stringify(err, null, 2))
  },
});

H5, H5+

copy
AlipayJSBridge.call('openLocation', {
  longitude: '120.126293',
  latitude: '30.274653',
  name: 'Huanglong Vanke Center...',
  address: '77 xueyuan road'
}, function (res) {
  alert('AlipayJSBridge openLocation result:\n' + JSON.stringify(res));
});

Parameters

Property

Type

Required

Description

longitude

String

Yes

The longitude.

latitude

String

Yes

The latitude.

name

String

Yes

The location.

address

String

Yes

The detailed address of the location.

scale

Number

No

The zoom level. The value ranges from 3 to 19 and is 15 by default.

success

Function

No

The callback method indicates a successful call.

fail

Function

No

The callback method indicates a failed call.

complete

Function

No

The callback method that indicates the call is completed (this will be executed regardless of whether the call succeeds or fails).