一、获取经纬度的接口

uni.getLocation({
	type: 'gcj02',
	success: function (res) {
		console.log('当前位置的经度:' + res.longitude);
		console.log('当前位置的纬度:' + res.latitude);
	},
	fail:function(res){
	   console.log(res)
	}
});

二、部署到服务器以后,不走这个接口,或者直接返回到fail函数中

在这里插入图片描述

解决办法:

根据官方文档介绍说:在较新的浏览器上,H5 端获取定位信息,要求部署在 https 服务上,本地预览(localhost)仍然可以使用 http 协议。

所以之前用 www.spaceobj.com直接访问的肯定访问不到,当你改成https://www.spaceobj.com访问的时候就可以了。
在这里插入图片描述

关注我的公众号SpaceObj 领取idea系列激活码

posted on 2023-05-10 17:56  张伯灵  阅读(93)  评论(0)    收藏  举报