mapcontext.clearroute(object object)
基础库 或更高版本; 且 支付宝客户端 10.1.32 或更高版本; 若版本较低,建议采取 兼容处理 。
小程序开发者工具: 支持。
主体: 企业支付宝小程序 、 个人支付宝小程序
相关文档: mapcontext.showroute
清除地图上的导航路线。
object object
查看示例
属性 | 类型 | 默认值 | 必填 | 描述 |
---|---|---|---|---|
success | function | - | 否 | 调用成功的回调函数 |
fail | function | - | 否 | 调用失败的回调函数 |
complete | function | - | 否 | 调用结束的回调函数(调用成功、失败都会执行) |
mapcontext.clearroute axml 代码
mapcontext.clearroute js 代码
<view>
<map id="map" style="width:100%; height:500px"/>
<button ontap="showroute">规划两点之间的路径</button>
<button ontap="clearroute">清除地图上的导航路线</button>
</view>
page({
data: {
mapctx: null
},
onready() {
this.data.mapctx = my.createmapcontext('map');
},
showroute() {
this.data.mapctx.showroute({
startlat: 30.257839, // 起点纬度
startlng: 120.062726, // 起点经度
endlat: 30.256718, // 终点纬度
endlng: 120.059985, // 终点经度
success: res => {
console.log(res, `总路程 ${res.distance} 米, 预计耗时 ${res.duration} 秒`);
},
fail: error => {
console.log(error);
}
});
},
clearroute() {
this.data.mapctx.clearroute();
}
});