当前位置:网站首页>Web technology sharing | [Gaode map] to realize customized track playback
Web technology sharing | [Gaode map] to realize customized track playback
2022-06-22 20:18:00 【51CTO】

Realization ( Track playback ) There are two ways :
- The first is to use
JS APIandAMap.PolyLine( Broken line ) And so on . - The second is to use
JS APIandAMapUI Component libraryIn combination with , utilizePathSimplifier( Trajectory display Components ) Draw the trajectory of action .
Options
We can implement the above two methods according to two factors To decide which one is more suitable for you : Number of nodes The amount of 、 The density of the arrangement .
The former is suitable for less nodes , The arrangement is sparse , for example , Taxi track playback , Taxis are fast , The periodic reporting time will also be relatively long . The latter is more specific to the large number of nodes 、 Arrange dense paths , Record the aircraft track of the position in seconds , Fine geographical boundaries, etc .
Implementation process
Either way , We all need to collect the information reported by the client first , This information can be customized , Usually we will include : Longitude and latitude 、 Speed 、 The geographical location after inverse coding 、 Direction 、 At an altitude of And other basic geographic information , We can also add some Customize Information about , for example : Personnel information ( Avatar nickname, etc )、 Travel information ( Orders, etc ).
The process of implementation :
- The client presses ( Time ) Periodically report geographic information and customized information .
- The server stores the information reported by the customer according to the time axis .
- Press ( Time and so on ) Query the user's track by conditions , And some nodes are removed by simplified algorithm ( for example , The node distance is very small 、 Or multiple points are in the same straight line 、3 Between points , There is a slight deviation in one point, which can not be drawn into a straight line, etc ), Finally, the path suitable for drawing ( Array ).
- Draw the user's action track according to the path .
Path simplification algorithm ( Optional )
The data reported by the client is reported according to the time cycle , That is to say, each time corresponds to a longitude and latitude , Longitude and latitude are one point after another on the map , When connecting these points , We will get N Multiple broken lines , In order to draw a more beautiful trajectory , The course of action is clearer and smoother , Usually we need an algorithm to simplify the polyline .
for example :
APoint andBspot , The distance between the two is less than1Pixels , You can get rid ofBspot , Just stayAspot .A,B,CThree points in a straight line , perhaps ,BThe point deviates only slightlyAPoint andCA line segment composed of points , thatBPoint can be removed .
An algorithm library is also recommended here simplify.js For your reference , I don't want to elaborate too much here .
Implementation example
Vehicle track playback
Here we use the first method to realize - utilize JS API and AMap.PolyLine.

Realization principle :
- Draw... On a map Vehicle markings (
AMap.Marker). - utilize
AMap.PolyLineDraw two tracks : The track of history and Track of driving path , Distinguish by color . - Drive the vehicle forward at a certain speed , And monitor
MakerMobile Events , In event callback , Put the vehicle (Marker) The location is set as the center point of the map , Give the user a subjective visual sense that the vehicle is moving forward , At the same time, extend Track of driving path . - For complex implementation scenarios , For example :
- View the data of each node , We can plot each node , When a node is clicked, the data of the node will be displayed .
- Mobile multipliers , First, play according to the reported time interval , After selecting double speed , change
MarKerThe mobileduration. - Other customizations .
Customize API
We can make the vehicle :
- Start moving
- Pause move
- Resume move
- Stop moving
Code example
Reference link : https://lbs.amap.com/demo/jsapi-v2/example/marker/replaying-historical-running-data
Playback of flight track
Use JS API and AMapUI Component library In combination with , utilize PathSimplifier( Trajectory display Components ) Draw the trajectory of action , This scheme is relatively simple , Only some configuration is required , For example, the double speed playback in scheme 1 needs to be calculated , At the same time, it also has the disadvantage of not dynamically changing the multiple speed , But scheme two will not exist .
Realization principle :
- Draw... On a map Aircraft marking (
AMap.Marker). - utilize
AMap.PolyLineDraw two tracks : The track of history and Track of driving path , Distinguish by color . - Configure the color of the track , Animation speed and so on .
- For complex implementation scenarios , Which need to be customized , Can be in
PathSimplifierConfiguration and processing in the callback provided .
Sample code
Reference link : https://lbs.amap.com/demo/amap-ui/demos/amap-ui-pathsimplifier/index

边栏推荐
- 【深入理解TcaplusDB技术】TcaplusDB进程
- Tree, forest and transformation of binary tree
- 防火墙基础之安全策略和NAT(Easy IP)
- 【深入理解TcaplusDB技术】TcaplusDB 新增业务集群cluster
- [deeply understand tcapulusdb technology] tcapulusdb table management - rebuild table
- [deeply understand tcapulusdb knowledge base] common problems in deploying tcapulusdb local
- 谷歌| ICML 2022: 深度强化学习中的稀疏训练状态
- 【深入理解TcaplusDB技术】TcaplusDB机型管理
- [deeply understand tcapulusdb technology] tcapulusdb transaction management - error troubleshooting
- 阿波罗使用注意事项
猜你喜欢

播放增长900w,B站用户叫好叫座的恰饭总结

Redis中的Multi事务

Zabbix学习笔记(三十七)

年中大促 | 集成无忧,超值套餐 6 折起

【深入理解TcaplusDB技术】入门Tcaplus SQL Driver

【深入理解TcaplusDB技术】TcaplusDB 表管理——清理表

Nlp-d57-nlp competition D26 & skimming questions D13 & reading papers & finding bugs for more than an hour

Yarn notes

510000 prize pool invites you to join the war! The second Alibaba cloud ECS cloudbuild developer competition is coming

Security policy and NAT (easy IP) of firewall Foundation
随机推荐
Definitions and terms of drawings
[in depth understanding of tcaplus DB technology] Introduction to tcaplus JDBC development
北京大学|通过对比学习实现离线元强化学习的鲁棒任务表示
Bubble sort, select sort, direct insert sort
Using span method to realize row merging of multi-layer table data
【深入理解TcaplusDB技术】创建游戏区
[deeply understand tcapulusdb knowledge base] common problems in deploying tcapulusdb local
【深入理解TcaplusDB技术】入门TcaplusDB 问题汇总
【深入理解TcaplusDB技术】TcaplusDB 表管理——清理表
Be careful with MySQL filesort
Shell Sort
【深入理解TcaplusDB知识库】部署TcaplusDB Local版常见问题
【深入理解TcaplusDB技术】TcaplusDB运维单据
【深入理解TcaplusDB技术】单据受理之创建业务指南
Random talk about redis source code 122
【深入理解TcaplusDB技术】TcaplusDB机型
web技术分享| 【高德地图】实现自定义的轨迹回放
Which securities firm is better to choose for opening an account in flush? Is it safe to open a mobile account?
Search, insert and delete of binary sort tree
#夏日挑战赛# 【FFH】从零开始的鸿蒙机器学习之旅-NLP情感分析