微信小程序实现路径规划
来源:互联网 发布:数据割接问题口径 编辑:程序博客网 时间:2024/06/06 19:22
通勤助手小程序使用了线路规划这一功能,借助腾讯地图的
WebService API中的路线规划服务和划线可实现这一功能。index.wxml文件如下,点击路线形成规划图。index.js文件如下
<map id="map" polyline="{{polyline}}"markers="{{markers}}"include-points="{{markers}}"style="width:100%; height:700rpx;"></map>
<buttonbindtap="end">路线</button>
index.js文件如下
var coors
var that2
Page({
data:{
polyline:[],
markers:[{
iconPath:"mark.png",
latitude:23.362490,
longitude:116.715790,
width:25,
height:25
},
{
iconPath:"mark.png",
latitude:23.37228,
longitude:116.75498,
width:25,
height:25
}],
},
onReady:function(){
that2 =this
wx.request({
url:'https://apis.map.qq.com/ws/direction/v1/driving/?from=23.362490,116.715790&to=23.37228,116.75498&output=json&callback=cb&key=22VBZ-REEK5-WVSI7-QKCOP-QPM6E-W7BPO',
success:function(res){
coors = res.data.result.routes[0].polyline
for(var i=2; i< coors.length; i++)
{ coors[i]= coors[i-2]+ coors[i]/1000000}
console.log(coors)
}
})
},
end:function(){
var b=[]
for(var i=0; i< coors.length; i=i+2)
{
b[i/2]={
latitude: coors[i],longitude:coors[i+1]}
console.log(b[i/2])
}
console.log(b.length)
that2.setData({
polyline:[{
points: b,
color:"#99FF00",
width:4,
dottedLine:false
}],
})
}
})
定义两点坐标并mark标注,通过api获取路径规划路线,返回的压缩后的经纬度,解压缩后出现成对的经纬度,再转换为polyline划线的格式。
- 微信小程序实现路径规划
- 路径规划的MATLAB实现
- 百度地图API实现定位+路径规划
- 平台转型-规划路径、实现落地
- 动态规划 python 实现 三角形最大值路径
- 转载:路径规划(最短路径)算法C#实现
- 路径规划(最短路径)算法C#实现[转]
- 路径规划(最短路径)算法C#实现
- 路径规划(最短路径)算法C#实现
- 路径规划(最短路径)算法C#实现
- 路径规划
- 路径规划
- 路径规划
- 路径规划
- 路径规划
- 路径规划
- openlayers通过pgrouting规划路径实现轨迹播放功能
- 百度地图SDK2.4.1 中实现路径规划
- $.ajax()详解
- C#获取当前窗体的受焦控件。
- PHP正则表达式匹配嵌套HTML标签的方法和技巧
- Python探索记(13)——字典Dictionary
- tomcat性能优化
- 微信小程序实现路径规划
- C++实训 单元九--STL输入输出流
- WAV格式学习
- mysql创建远程用户并授权
- Markdown--StackEdit
- BZOJ 3119 贪心 解题报告
- 数据结构绪论
- 移动端 触摸事件 ontouchstart、ontouchmove、ontouchend、ontouchcancel
- 深入理解Java注解(Annotation)-自定义注解