mapcontext.screentomap(object object)
基础库 或更高版本; 且 支付宝客户端 10.1.92 或更高版本; 若版本较低,建议采取 兼容处理 。
小程序开发者工具: 不支持。
主体: 企业支付宝小程序 、 个人支付宝小程序
将屏幕上坐标点转换成对应地图上经纬度。
object object
查看示例
属性 | 类型 | 默认值 | 必填 | 描述 |
---|---|---|---|---|
x | number | - | 是 | 横坐标 |
y | number | - | 是 | 纵坐标 |
success | function | - | 否 | 调用成功的回调函数 |
fail | function | - | 否 | 调用失败的回调函数 |
complete | function | - | 否 | 调用结束的回调函数(调用成功、失败都会执行) |
success 回调函数
参数
object res
属性 | 类型 | 描述 |
---|---|---|
latitude | number | 纬度 |
longitude | number | 经度 |
fail 回调的参数为 object,error
属性为错误码,errormessage
属性为错误消息。
错误码 | 错误消息 | 凯发app官方网站的解决方案 |
---|---|---|
2 | 接口参数无效 |
请正确填写参数。 |
mapcontext.screentomap axml 代码
mapcontext.screentomap js 代码
<view>
<map id="map" style="width:100%; height:500px"/>
<button ontap="screentomap">坐标点转换</button>
</view>
page({
data: {
mapctx: null,
},
onready() {
this.mapctx = my.createmapcontext("map");
},
screentomap() {
this.mapctx.screentomap({
x: 0,
y: 0,
success: res => {
console.log(res);
},
fail: error => {
console.log(error)
}
});
},
});
-
bug支付宝 10.3.70 版本之前,ios 环境中入参错误不会执行回调函数,安卓环境中不会校验入参的类型。请在使用 api 时确保入参正确。