微信小程序,经纬度判断距离搜索
(我自己记录看的,本地文件在demo、demo01.xml)
微信小程序中获取自己的经纬度:
wxml:
<view>当前你的经纬度是{
{latitude}}--{
{longitude}}</view>
wxjs:
// pages/map/map.js
Page({
/**
* 页面的初始数据
*/
data: {
latitude: "",
longitude: "",
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var that = this
//获取当前的地理位置、速度
wx.getLocation({
type: 'wgs84', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
altitude:true,
isHighAccuracy:true,
highAccuracyExpireTime:6000,
success: function (res) {
//赋值经纬度
that.setData({
latitude: res.latitude,
longitude: res.longitude,
});
console.log("坐标系——WGS84");
console.log(res.latitude);
console.log(res.longitude);
}