Home  >  Article  >  Web Front-end  >  How to get your location in WeChat mini program

How to get your location in WeChat mini program

亚连
亚连Original
2018-06-23 15:11:361228browse

This article mainly introduces the function of WeChat applet to obtain the longitude and latitude coordinates of your location, and involves the related operation skills of WeChat applet map function to obtain longitude and latitude information. Friends in need can refer to this article

The example describes a WeChat applet that implements the function of obtaining the longitude and latitude coordinates of your location. Share it with everyone for your reference, the details are as follows:

1. Effect display

2. Key code

index.wxml layout file Code

<view>纬度:{{latitude}}</view>
<view>经度:{{longitude}}</view>

index.js logic file code

Page({
 data: {
  latitude:&#39;&#39;,
  longitude:&#39;&#39;
 },
 onLoad: function () {
  var that=this;
  wx.getLocation({
   type: &#39;wgs84&#39;,
   success: function(res) {
    that.setData({
     latitude:res.latitude,
     longitude:res.longitude
    })
   }
  })
 }
})

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

How to pop up the bottom menu in the WeChat mini program

How to use slider to set data in the WeChat mini program Value

How to create a child process using node.js (detailed tutorial)

How to implement singleton mode using ES6

The above is the detailed content of How to get your location in WeChat mini program. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn