mapcontext.setmaptype(object object)
基础库 或更高版本; 且 支付宝客户端 10.1.92 或更高版本; 若版本较低,建议采取 兼容处理 。
小程序开发者工具: 不支持。
主体: 企业支付宝小程序 、 个人支付宝小程序
设置地图类型。
object object
查看示例
属性 | 类型 | 默认值 | 必填 | 描述 | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
maptype | number | - | 是 | 地图类型 |
|||||||||||||||||||
|
|||||||||||||||||||||||
success | function | - | 否 | 调用成功的回调函数 |
|||||||||||||||||||
fail | function | - | 否 | 调用失败的回调函数 |
|||||||||||||||||||
complete | function | - | 否 | 调用结束的回调函数(调用成功、失败都会执行) |
fail 回调的参数为 object,error
属性为错误码,errormessage
属性为错误消息。
错误码 | 错误消息 | 凯发app官方网站的解决方案 |
---|---|---|
2 | 接口参数无效。 |
参数类型错误,请填写正确的参数类型。 |
mapcontext.setmaptype axml 代码
mapcontext.setmaptype js 代码
<view>
<map id='map' style="width:100%; height:500px"/>
<button ontap="setmaptype">设置地图类型</button>
</view>
page({
data: {
mapctx: null
},
onready() {
this.mapctx = my.createmapcontext('map');
},
// 设置地图类型
setmaptype() {
this.mapctx.setmaptype({
maptype: 1,
success: res => {
console.log(res);
},
fail: error => {
console.log(error)
}
});
}
});
-
bug支付宝 10.3.70 以下版本,安卓 ios 环境不会检测入参类型。若类型错误,安卓会走 success 回调函数并返回
success: true
,ios 则不执行回调函数。请仔细填写入参。