mapcontext.getcenterlocation(object object)
基础库 或更高版本; 且 支付宝客户端 10.1.32 或更高版本; 若版本较低,建议采取 兼容处理 。
以 promise 风格调用: 支持 。
主体: 企业支付宝小程序 、 个人支付宝小程序
获取当前地图中心位置。
object object
查看示例
属性 | 类型 | 默认值 | 必填 | 描述 |
---|---|---|---|---|
success | function | - | 否 | 调用成功的回调函数 |
fail | function | - | 否 | 调用失败的回调函数 |
complete | function | - | 否 | 调用结束的回调函数(调用成功、失败都会执行) |
success 回调函数
参数
object res
查看示例
属性 | 类型 | 描述 |
---|---|---|
latitude | number | 纬度 |
longitude | number | 经度 |
scale | number | 缩放级别 |
mapcontext.getcenterlocation(object object)
success 参数
// .js
this.mapctx = my.createmapcontext('map');
this.mapctx.getcenterlocation({
success: res => {
my.alert({
content: 'longitude:' res.longitude '\nlatitude:' res.latitude,
});
console.log(res.longitude);
console.log(res.latitude);
}
});
{
"longitude": 120.131441,
"latitude": 30.279383,
"scale": 16
}