增加地址解析

This commit is contained in:
yuguojian
2025-07-17 17:29:22 +08:00
parent d0d264d1e7
commit 7e75d5f5eb
2 changed files with 5 additions and 5 deletions

View File

@@ -88,7 +88,7 @@ func (n *AnNaQiGpsClient) GetGpsInfo(longitude, latitude float64) (res *AddressC
return nil, errors.New(fmt.Sprintf("获取gps:%s信息失败%+v", location, apiResult))
}
func (n *AnNaQiGpsClient) GetLocation(city, region, address string) (res *[]Geocode, err error) {
func (n *AnNaQiGpsClient) GetLocation(city, region, address string) (res []*Geocode, err error) {
values := url.Values{}
values.Set("city", city)
values.Set("address", region+address)
@@ -136,8 +136,8 @@ func (n *AnNaQiGpsClient) GetLocation(city, region, address string) (res *[]Geoc
}
// 检查API返回状态
if locationInfo.Code == 200 {
if len(locationInfo.Data.Geocodes) > 0 {
return &locationInfo.Data.Geocodes, nil
if locationInfo.Data.Count > 0 {
return locationInfo.Data.Geocodes, nil
}
}

View File

@@ -65,7 +65,7 @@ type LocationInfo struct {
type LocationDatum struct {
Count int `json:"count"`
Geocodes []Geocode `json:"geocodes"`
Geocodes []*Geocode `json:"geocodes"`
}
type Geocode struct {