Vue implementation of the WEB side positioning function acquisition latitude and longitude

First, the needs of my life are to get the current user’s latitude and longitude

After countless tests, I used Tencent / Baidu map API, and finally the JS API

There is not much nonsense, directly on the code. vue 实现Web端的定位功能 获取经纬度

First introduced in Index.html

     
Then go to the page you need to get started, I will test it here, so there is only one app.vue file.

It seems that it is already very detailed.

By calling Google’s API, it can achieve accurate positioning, vue 实现Web端的定位功能 获取经纬度
Function OnComplete (data) {// This is a thing that occurs after obtaining location service Here I gain the desired information directly} Function OneRror (data) {// This is after obtaining the positioning failure, the implementation, // I set it up here, after the acquisition failed, enable IP positioning // But there is a little 嗷It is not very accurate, and Android WeChat has been tested, only here. }

Next:

  Function OnComplete (data) {// This is allowed to get location What happened after the service, here I got the information directly} Function OneRror (data) {// This is after obtaining the positioning failure, the implementation, // What I set here is after the acquisition failure, enable IP positioning / / But there is a little, it is not very accurate, and Android WeChat has been tested and can only go here.}  
Test:

IOS model, perfectly positioned in WeChat built-in browser or other browser

Android Type, in the WeChat built-in browser displays failed, transferred to IP positioning, slightly deviation, but not super large, but in other browsers can implement accurate positioning.
   
The above is the Vue to realize the Vue to realize the WEB side positioning function, I hope that if you have any questions if you have any questions. Please leave a message, the small package will reply to everyone in time. Thank you very much for your support of Tumi Cloud Website!
If you think this article helps you, welcome to reprint, please indicate the source, thank you!

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment