自己动手实现一个跑步小程序 用到的方法:wx.onLocationChange,监听实时地理位置变化事件,需结合 wx.startLocationUpdateBackground,wx.startLocationUpdate使用。
地图组件
定义一个全屏的地图,地图配置项经纬度(longitude,latitude),缩放(scale),标记点(markers),路线(polyline)等
<view class="map"><map id="map" longitude="{
{longitude}}" latitude="{
{latitude}}" scale="{
{scale}}" markers="{
{markers}}"polyline="{
{polyline}}" style="width: 100%; height: 100%"></map>
</view>
地图配置项字段
data: {latitude: '',longitude: '',scale: 16,markers: [],polyline: [{points: [],color: '#FB8337',width: 5}]
},
当前位置
用wx.getLocation获取当前位置,
// 获取当前位置
getNowLocation() {wx.getLocation({type: 'gcj02',isHighAccuracy: true,success: (res) => {this.setD

本文介绍了如何动手实现一个跑步小程序,包括使用wx.onLocationChange监听实时地理位置、地图组件配置、获取及显示当前位置、设置GPS定位、后台定位以及绘制跑步路线。同时提到了Vue的相关学习资源。
最低0.47元/天 解锁文章
839

被折叠的 条评论
为什么被折叠?



