This commit is contained in:
suyl
2021-05-11 15:42:06 +08:00
parent d2de04d1ac
commit 5c6f604d7d
3 changed files with 71 additions and 5 deletions

View File

@@ -67,3 +67,61 @@ func (a *API) GetCoordinateFromAddressByPage(address string, cityCode int) (lng,
}
return lng, lat, err
}
type GetCoordinateFromAddressByPageAllResult struct {
Suggestion struct {
Keywords []interface{} `json:"keywords"`
Cities []interface{} `json:"cities"`
} `json:"suggestion"`
Count string `json:"count"`
Infocode string `json:"infocode"`
Pois []struct {
Parent []interface{} `json:"parent"`
Address string `json:"address"`
Distance []interface{} `json:"distance"`
Pname string `json:"pname"`
Importance []interface{} `json:"importance"`
BizExt struct {
Cost []interface{} `json:"cost"`
Rating []interface{} `json:"rating"`
} `json:"biz_ext"`
BizType []interface{} `json:"biz_type"`
Cityname string `json:"cityname"`
Type string `json:"type"`
Photos []interface{} `json:"photos"`
Typecode string `json:"typecode"`
Shopinfo string `json:"shopinfo"`
Poiweight []interface{} `json:"poiweight"`
Childtype []interface{} `json:"childtype"`
Adname string `json:"adname"`
Name string `json:"name"`
Location string `json:"location"`
Tel string `json:"tel"`
Shopid []interface{} `json:"shopid"`
ID string `json:"id"`
} `json:"pois"`
Status string `json:"status"`
Info string `json:"info"`
}
func (a *API) GetCoordinateFromAddressByPageAll(address string, cityCode int) (getCoordinateFromAddressByPageAllResult *GetCoordinateFromAddressByPageAllResult, err error) {
result, err := a.AccessStorePage("https://restapi.amap.com/v3/place/text", map[string]interface{}{
"s": "rsv3",
"key": "e07ffdf58c8e8672037bef0d6cae7d4a",
"page": 1,
"offset": 10,
"city": cityCode,
"language": "zh_cn",
"platform": "JS",
"logversion": 2.0,
"sdkversion": 1.3,
"appname": "https://lbs.amap.com/console/show/picker",
"csid": "7A90908C-BBA6-49FE-895E-DB70600E14F8",
"keywords": address,
"children": "",
})
if err == nil {
utils.Map2StructByJson(result, &getCoordinateFromAddressByPageAllResult, false)
}
return getCoordinateFromAddressByPageAllResult, err
}

View File

@@ -14,3 +14,11 @@ func TestGetCoordinateFromAddressByPage(t *testing.T) {
t.Log(utils.Format4Output(lng, false))
t.Log(utils.Format4Output(lat, false))
}
func TestGetCoordinateFromAddressByPageAll(t *testing.T) {
result, err := autonaviAPI.GetCoordinateFromAddressByPageAll("兴月宏干杂", 510100)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}

View File

@@ -6,11 +6,11 @@ import (
)
func TestOptimusMaterial(t *testing.T) {
result, err := api.OptimusMaterial(28026, 111339100149, 1, 20)
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
//result, err := api.OptimusMaterial(28026, 111339100149, 1, 20)
//if err != nil {
// t.Fatal(err)
//}
//t.Log(utils.Format4Output(result, false))
}
func TestMaterialOptional(t *testing.T) {