mapcontext.translatemarker(object object)
基础库 或更高版本; 且 支付宝客户端 10.1.50 或更高版本; 若版本较低,建议采取 兼容处理 。
小程序开发者工具: 支持。3.8.3 版本开始支持。
主体: 企业支付宝小程序 、 个人支付宝小程序
平移点标记。
若对同一个点标记执行多次平移,须在前一次平移 animationend 发生以后再调用后一次 translatemarker。
object object
查看示例
属性 | 类型 | 默认值 | 必填 | 描述 | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
markerid | number | - | 是 | 指定 marker |
||||||||||
destination | object | - | 是 | 指定 marker 移动到的目标点 |
||||||||||
|
||||||||||||||
autorotate | boolean | true | 否 | 移动过程中是否自动旋转 marker |
||||||||||
rotate | number | 0 | 否 | marker 的旋转角度 |
||||||||||
duration | number | 1000 | 否 | 动画持续时长,单位为毫秒 |
||||||||||
animationend | function | - | 否 | 动画结束回调函数 |
||||||||||
success | function | - | 否 | 调用成功的回调函数 |
||||||||||
fail | function | - | 否 | 调用失败的回调函数 |
||||||||||
complete | function | - | 否 | 调用结束的回调函数(调用成功、失败都会执行) |
mapcontext.translatemarker axml 代码
mapcontext.translatemarker js 代码
<view
<map id="map" style="width:100%; height:500px"></map>
<button ontap="translatemarker">平移点标记</button
</view
page({
data: {
mapctx: null
},
onready() {
this.data.mapctx = my.createmapcontext('map');
},
translatemarker() {
this.data.mapctx.translatemarker({
markerid: 0,
destination: {
longitude: 120.2,
latitude: 30.3,
},
autorotate: true,
rotate: 90, // 选填,在autorotate为false的情况下才有效,不填默认是0
duration: 900, // 选填,单位ms,默认1000 ms
animationend: () => {
console.log('animation end');
}, // function 动画结束回调
success: (res) => {
console.log(res);
},
fail: (error) => {
console.log(error);
}
});
}
});