diff --git a/gps_tool/an_na_qi_client.go b/gps_tool/an_na_qi_client.go index 639a5ab..51d12de 100644 --- a/gps_tool/an_na_qi_client.go +++ b/gps_tool/an_na_qi_client.go @@ -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 } } diff --git a/gps_tool/response.go b/gps_tool/response.go index b0cb061..1150bfe 100644 --- a/gps_tool/response.go +++ b/gps_tool/response.go @@ -64,8 +64,8 @@ type LocationInfo struct { } type LocationDatum struct { - Count int `json:"count"` - Geocodes []Geocode `json:"geocodes"` + Count int `json:"count"` + Geocodes []*Geocode `json:"geocodes"` } type Geocode struct {