4 years ago (2015-12-14)  Software development |   First to comment  47 
post score 0 times, average 0.0

In WeChat development, we often need to know the location of the user. We provide a way to access geographical locations in WeChat's JS-SDK. This does not require that your public number is an authentication account, and ordinary uncertified subscription numbers also have access to geographic locations.

Wechat Development Get Location and Baidu Maps Longitude and Latitude Analysis

According to the JSSDK steps in the WeChat public number developer documentation

  • 1.1.1 Step 1: Bind the domain name
  • 1.1.2 Step 2: Importing JS Files
  • 1.1.3 Step 3: Inject privilege verification configuration through config interface
  • 1.1.4 Step 4: Process successful authentication through the ready interface
  • 1.1.5 Step 5: Process Failure Authentication Through the error Interface

Wechat development location and Baidu map latitude and longitude analysis, we can get a lot of advanced features according to the official document, not repeat them here.Perhaps tricky is the message signing problem that comes later.Here is the official code:

Called in PHP:

Add js code in HTML:

Call the js code to get latitude and longitude:

Baidu map latitude and longitude analysis

The WeChat JS-SDK only provides latitude and longitude, rather than a geographic location like “Xi'an, Shaanxi Province”. The following is a PHP function that converts latitude and longitude to a geographic location. The Baidu map web-api is called:

 

This article has been printed on copyright and is protected by copyright laws. It must not be reproduced without permission.If you need to reprint, please contact the author or visit the copyright to obtain the authorization. If you feel that this article is useful to you, you can click the "Sponsoring Author" below to call the author!

Reprinted Note Source: Baiyuan's Blog>>https://wangbaiyuan.cn/en/get-position-with-baidu-map-wechat-development-latitude-longitude-resolution-2.html

Post comment

Style

No Comment

登录

Forget password?

您也可以使用第三方帐号快捷登录

切换登录

注册

TW