最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
微信小程序实现导航功能操作代码示例
时间:2021-03-10 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下微信小程序实现导航功能操作代码示例,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
一、效果图
二、操作步骤
1、申请腾讯地图key——地址
2、小程序后台添加腾讯插件——开发文档
3、小程序代码app.json设置
let plugin = requirePlugin('routePlan'); let key = ''; //使用在腾讯位置服务申请的key let referer = ''; //调用插件的app的名称 let endPoint = JSON.stringify({ //终点 'name': '吉野家(北京西站北口店)', 'latitude': 39.89631551, 'longitude': 116.323459711 }); wx.navigateTo({ url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint });
或者也可以使用小程序内置地图导航
使用小程序内置地图wx.getLocation和wx.openLocation
官网链接
//wxml
//js Page({ data: { }, openMap: function () { wx.getLocation({ type: 'gcj02', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 success: function (res) { // success console.log(res.latitude); console.log(res.longitude); wx.openLocation({ latitude: res.latitude, // 纬度,范围为-90~90,负数表示南纬 longitude: res.longitude, // 经度,范围为-180~180,负数表示西经 scale: 28, // 缩放比例 name:"要找的地方名字(某某饭店)", address:"地址:要去的地点详细描述" }) } }) } })
相关文章
- SpringBoot测试配置属性与web启动环境解析 10-24
- SpringBoot常用计量与bean属性校验和进制数据转换规则解析 10-24
- 工厂方法在Spring框架中的运用介绍 10-24
- SpringBoot热部署设置详解 10-24
- JavaScript二叉搜索树构建操作解析 10-12
- JavaScript二叉树及各种遍历算法讲解 10-12