4601关注13915浏览
地图和定位可以在电脑上正常显示,但是在手机上无法获得准确定位
- 预期表现
- 复现路径
- 提供一个最简复现 Demo
<!--pages/parking/parking.wxml-->
<view class='container'>
<map longitude="{{longitude}}" latitude="{{latitude}}" markers='{{markers}}' style='width:100%;height:{{view.Height}}px;'>
<cover-view class='header'>
<cover-view class='text'>暂时还没有登录,请登录后体验更多功能</cover-view>
<cover-view class='btn btn-login' bindtap='login'>马上登录</cover-view>
</cover-view>
<cover-view class='footer'>
<cover-view class='btn btn-more' bindtap='parkList'>查看全部</cover-view>
</cover-view>
</map>
</view>
/**
* 页面的初始数据
*/
data: {
latitude: '',
longitude: '',
Height: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var _this = this;
if (app.globalData.latitude && app.globalData.longitude) {
this.setData({
latitude: app.globalData.latitude, // 经度
longitude: app.globalData.longitude, // 纬度
markers: [{
id: 1,
latitude: app.globalData.latitude, // 经度
longitude: app.globalData.longitude, // 纬度
width: 20,
height: 30,
iconPath: '/img/location.png'
}]
})
}
wx.getSystemInfo({
success: function (res) {
_this.setData({
view: {
Height: res.windowHeight
}
})
}
})
},
-
至过去的我
2044人对此回答表示赞同
我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多> -
文心雕龙
15人对此回答表示赞同
麻烦给个相关的代码片段,我们定位下问题
展开150回复分享发布于 6年前评论(0)
收起评论