How to achieve real-time positioning on the mobile web side
The WeChat public account can obtain the location of the courier in real time. Is there any good solution or interface?
Reply content:
The WeChat public account can obtain the location of the courier in real time. Is there any good solution or interface?
Html5 itself can obtain the geographical location (WGS-84)
But the premise is that the courier keeps opening that web page without a black screen. After the black screen, the script in the web page will be suspended (so the GPS will also be stopped).
The official account will only read the coordinates and upload them to the background when entering the main interface. After entering the Web page, the permissions will be reduced to the same as HTML.
The JS API of the official account will not continuously obtain the coordinates, unless setInterval keeps fetching them, and the JS will stop after the black screen.
If you need to upload the courier's coordinates to the server in real time, the only way is APP.
The method of obtaining geographical location on the Web: navigator.geolocation has three functions:
<code>void getCurrentPosition(onSuccess,onError,options); //获取用户当前位置 int watchCurrentPosition(onSuccess,onError,options); //持续获取当前用户位置 void clearWatch(watchId); //watchId 为watchCurrentPosition返回的值 //取消监控</code>
<code> function getLocation(){ var options={ enableHighAccuracy:true, maximumAge:1000 } if(navigator.geolocation){ //浏览器支持geolocation navigator.geolocation.watchCurrentPosition(onSuccess,onError,options); }else{ //浏览器不支持geolocation } } //成功时 function onSuccess(position){ //返回用户位置 //经度 var longitude =position.coords.longitude; //纬度 var latitude = position.coords.latitude; } //失败时 function onError(error){ switch(error.code){ case 1: alert("位置服务被拒绝"); break; case 2: alert("暂时获取不到位置信息"); break; case 3: alert("获取信息超时"); break; case 4: alert("未知错误"); break; } } //开始获得 getLocation();</code>
How to convert WGS-84 to Tencent/Baidu coordinates, please go to https://www.oschina.net/code/...

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

How does the Redis caching solution realize the requirements of product ranking list? During the development process, we often need to deal with the requirements of rankings, such as displaying a...

Redis plays a key role in data storage and management, and has become the core of modern applications through its multiple data structures and persistence mechanisms. 1) Redis supports data structures such as strings, lists, collections, ordered collections and hash tables, and is suitable for cache and complex business logic. 2) Through two persistence methods, RDB and AOF, Redis ensures reliable storage and rapid recovery of data.

IIS and PHP are compatible and are implemented through FastCGI. 1.IIS forwards the .php file request to the FastCGI module through the configuration file. 2. The FastCGI module starts the PHP process to process requests to improve performance and stability. 3. In actual applications, you need to pay attention to configuration details, error debugging and performance optimization.

Safely handle functions and regular expressions in JSON In front-end development, JavaScript is often required...

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.

Why is the return value empty when using RedisTemplate for batch query? When using RedisTemplate for batch query operations, you may encounter the returned results...

The optimization solution for SpringBoot timing tasks in a multi-node environment is developing Spring...
