在地图上定位用户的位置
wx.getLocation({ //获取当前经纬度
type: 'gcj02',
altitude: true, //高精度定位
//定位成功,更新定位结果
success: res => {
console.log(res);
console.log(this);
this.longitude = res.longitude;
this.latitude = res.latitude;
this.speed = res.speed;
this.accuracy = res.accuracy;
this.$apply();
},
//定位失败回调
fail: function() {
wx.showToast({
title: '定位失败',
icon: 'none'
});
},
complete: function() {
//隐藏定位中信息进度
wx.hideLoading();
}
});
在地图上标识商家所有店铺的位置
<map
id="map"
longitude="{{longitude}}"
latitude="{{latitude}}"
markers="{{markers}}" //标识位置
include-points="{{markers}}"
covers="{{covers}}"
show-location
bindmarkertap="showModal" //点击标识出现弹窗
style="width: 100%; height: 300px;"
bindtap="hiddenmodal"
>