前期为traccar做了一个4.8版本的高德地图适配版,现在源版本升级,本次应许多朋友的要求,在traccar-server源代码的基础上,为高德地图重新做了适配,解决了使用高德地图发生偏移情况。
这次只适配了部分常用协议,不保证使用中可能会出现未知的问题,如果有问题请跟贴。
为方便大家使用,做成了docker镜像。
一、安装过程:
1、在Docker管理界面,从URL安装
2、输入网址“https://hub.docker.com/r/bg6rsh/traccar-amap”
3、下载过程
4、下载完成后,双击下载的映像,生成容器
5、进入“高级设置”,按下面图片进行设置
按下图设置映射目录,将Docker内部目录,映射到群晖目录中,方便修改设置,备份数据文件
6、按教程设置完后,点“应用”运行服务
7、运行后映射目录中的内容如下,
其中“default.xml”文件不要修改,“traccar.xml”需要根据情况设定。
8、traccar.xml设置说明:
Code: [全选] [Expand/Collapse]
-
<?xml version=‘1.0’ encoding=‘UTF-8’?>
-
-
<!DOCTYPE properties SYSTEM ‘http://java.sun.com/dtd/properties.dtd’>
-
-
<properties>
-
-
<entry key=‘config.default’>./conf/default.xml</entry>
-
-
<!–
-
-
This is the main configuration file. All your configuration parameters should be placed in this file.
-
-
Default configuration parameters are located in the "default.xml" file. You should not modify it to avoid issues
-
with upgrading to a new version. Parameters in the main config file override values in the default file. Do not
-
remove "config.default" parameter from this file unless you know what you are doing.
-
-
For list of available parameters see following page: https://www.traccar.org/configuration-file/
-
-
–>
-
<!– 数据库连接参数,如果要连接到mysql数据库,请修改此处 –>
-
<entry key=‘database.driver’>org.h2.Driver</entry>
-
<entry key=‘database.url’>jdbc:h2:./data/database</entry>
-
<entry key=‘database.user’>sa</entry>
-
<entry key=‘database.password’></entry>
-
-
<!– 高德地图逆地理编码设置 –>
-
<entry key=‘geocoder.enable’>true</entry>
-
<entry key=‘geocoder.format’>%f</entry>
-
<!– 下面’geocoder.key’参数需要在高德网上申请一个自己专用的“web服务器”key –>
-
<entry key=‘geocoder.key’>de6cf58608a044b643da48377c6bdbfb</entry>
-
<entry key=‘geocoder.type’>amap</entry>
-
<entry key=‘geocoder.url’>https://restapi.amap.com/v3/geocode/regeo</entry>
-
-
</properties>
如果使用的是MySQL数据库,连接参数请参照下面设置
Code: [全选] [Expand/Collapse]
-
<entry key=‘database.driver’>com.mysql.cj.jdbc.Driver</entry>
-
<entry key=‘database.url’>jdbc:mysql://192.168.3.8:3307/traccar?serverTimezone=UTC&useSSL=false&allowMultiQueries=true&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&sessionVariables=sql_mode=”</entry>
-
<entry key=’database.user’>traccar</entry>
-
<entry key=’database.password’>12345678</entry>
9、去“高德开放平台”https://lbs.amap.com/ 注册一个账号,可以用支付宝、淘宝账号登录。
大家一定要申请自己的“Web服务”KEY,因为高德免费的逆地理编码3000000次/日,如果大家都用这个,那就用不了多长时间了。这个KEY只是提供大家测试用,不保证能用多长时间。怎么申请网上有很多介绍,大家可自行查找。
原文作者: BG6RSH | 查看原帖