将所有地图改为腾讯地图
This commit is contained in:
111
platformapi/tencent_map/tencent_test.go
Normal file
111
platformapi/tencent_map/tencent_test.go
Normal file
@@ -0,0 +1,111 @@
|
||||
package tencent_map
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"go.uber.org/zap"
|
||||
"testing"
|
||||
)
|
||||
|
||||
var (
|
||||
tencent *API
|
||||
sugarLogger *zap.SugaredLogger
|
||||
)
|
||||
|
||||
func init() {
|
||||
logger, _ := zap.NewDevelopment()
|
||||
sugarLogger = logger.Sugar()
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
tencent = New("Q2KBZ-YXFLN-LEVFD-STWQY-6RBBE-A4FLF", "vIO9yPPnp4pWmIywsR1DHCu0OFpQONeW")
|
||||
}
|
||||
|
||||
// 坐标转换
|
||||
func TestCoordinateChange(t *testing.T) {
|
||||
result, err := tencent.TencentCoordinateChange(&TencentCoordinateChangeReq{
|
||||
Locations: "34.260369,117.138444",
|
||||
Type: CoordinateChangeTypeGaoDe,
|
||||
//Output: "json",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
} else {
|
||||
t.Log(result)
|
||||
}
|
||||
}
|
||||
|
||||
// 骑行规划
|
||||
func TestTencentCyclingPlanning(t *testing.T) {
|
||||
distance, duration, point, err := tencent.TencentCyclingPlanning(&TencentCyclingPlanningReq{
|
||||
Key: tencent.key,
|
||||
From: "30.637486,103.919896",
|
||||
To: "30.604708,103.913647",
|
||||
})
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
} else {
|
||||
t.Log(distance)
|
||||
t.Log(duration)
|
||||
t.Log(point)
|
||||
}
|
||||
}
|
||||
|
||||
// 地址解析坐标
|
||||
func TestGetCoordinateFromAddress(t *testing.T) {
|
||||
lng, lat, code, name, err := tencent.GetCoordinateFromAddress("四川省成都市双流区九江街道中国浩森国际装饰建材城-13幢", "")
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
} else {
|
||||
t.Log(lng)
|
||||
t.Log(lat)
|
||||
t.Log(code)
|
||||
t.Log(name)
|
||||
}
|
||||
}
|
||||
|
||||
// 坐标解析地址
|
||||
func TestGeoCodeRegeoSingle(t *testing.T) {
|
||||
tencent.GeoCodeRegeoSingle(116.307490, 39.984154, 0, false, nil, 0, 0)
|
||||
}
|
||||
|
||||
// 获取全国行政区划 List
|
||||
func TestGetDistricts(t *testing.T) {
|
||||
result, err := tencent.GetDistricts(2, "510000", 2)
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
} else {
|
||||
t.Log(result)
|
||||
}
|
||||
}
|
||||
|
||||
// 根据ID获取部分行政区划
|
||||
func TestGetSecondaryDivision(t *testing.T) {
|
||||
data, err := tencent.GetSecondaryDivision(2, "511300", 2)
|
||||
if err != nil {
|
||||
t.Log(err)
|
||||
} else {
|
||||
t.Log(data)
|
||||
}
|
||||
}
|
||||
|
||||
// 批量获取距离
|
||||
func TestBatchWalkingDistance(t *testing.T) {
|
||||
tencent.BatchWalkingDistance(103.913647, 30.604708, append([]*Coordinate{}, &Coordinate{
|
||||
Lng: 103.914001,
|
||||
Lat: 30.611431,
|
||||
}))
|
||||
}
|
||||
|
||||
// 根据坐标获取地址和区域代买
|
||||
func TestGetCoordinateTownInfo(t *testing.T) {
|
||||
name, code := tencent.GetCoordinateTownInfo(113.756791, 23.041187)
|
||||
t.Log(name)
|
||||
t.Log(code)
|
||||
}
|
||||
|
||||
// 获取定位市区坐标
|
||||
func TestGetCoordinateCityInfo(t *testing.T) {
|
||||
name, code := tencent.GetCoordinateCityInfo(113.756791, 23.041187)
|
||||
t.Log(name)
|
||||
t.Log(code)
|
||||
}
|
||||
Reference in New Issue
Block a user