Home > Web Front-end > JS Tutorial > body text

Example sharing of WeChat applet to obtain the latitude and longitude coordinates of your location

小云云
Release: 2018-05-28 14:19:24
Original
3072 people have browsed it

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 who need it can refer to it. I hope it can help everyone.

1. Effect display

2. Key code

index.wxml layout file code

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

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
    })
   }
  })
 }
})
Copy after login

Related recommendations:

php Tencent map longitude and latitude conversion to Baidu map longitude and latitude implementation ideas and example sharing

##js Introduction to the method of automatically filling longitude and latitude into the text box

Detailed explanation of the graphic and text code for converting longitude and latitude into addresses using JavaScript

The above is the detailed content of Example sharing of WeChat applet to obtain the latitude and longitude coordinates of your location. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template