效果图
![](https://i-blog.csdnimg.cn/blog_migrate/16e472ea7187df43756e2ba998b38fb8.png)
准备工作
![](https://i-blog.csdnimg.cn/blog_migrate/8b46c9e4f8871dd54bf52de1ca775bae.png)
manifest.json
"plugins": {
"routePlan": {
"version": "1.0.12",
"provider": "wx50b5593e81dd937a"
}
},
"permission": {
"scope.userLocation": {
"desc": "位置信息"
}
},
![](https://i-blog.csdnimg.cn/blog_migrate/9d4b5fec0d97de68a89cb0627c012103.png)
页面使用(点击事件为Routing,传入地址名称,经纬度)
Routing(placeName, lat, lon) {
let plugin = requirePlugin('routePlan');
let key = 'xxxxx'; // 使用在腾讯位置服务申请的key
let referer = 'gsbj'; // 调用插件的app的名称
let navigation = 1 // 值为1时,开启驾车导航功能;默认不开启此功能
let endPoint = JSON.stringify({ // 终点
'name': placeName,
'latitude': lat,
'longitude': lon
});
wx.navigateTo({
url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint + '&navigation=' + navigation
});
}