Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7e75d5f5eb |
@@ -88,7 +88,7 @@ func (n *AnNaQiGpsClient) GetGpsInfo(longitude, latitude float64) (res *AddressC
|
|||||||
return nil, errors.New(fmt.Sprintf("获取gps:%s信息失败,%+v", location, apiResult))
|
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 := url.Values{}
|
||||||
values.Set("city", city)
|
values.Set("city", city)
|
||||||
values.Set("address", region+address)
|
values.Set("address", region+address)
|
||||||
@@ -136,8 +136,8 @@ func (n *AnNaQiGpsClient) GetLocation(city, region, address string) (res *[]Geoc
|
|||||||
}
|
}
|
||||||
// 检查API返回状态
|
// 检查API返回状态
|
||||||
if locationInfo.Code == 200 {
|
if locationInfo.Code == 200 {
|
||||||
if len(locationInfo.Data.Geocodes) > 0 {
|
if locationInfo.Data.Count > 0 {
|
||||||
return &locationInfo.Data.Geocodes, nil
|
return locationInfo.Data.Geocodes, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -64,8 +64,8 @@ type LocationInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type LocationDatum struct {
|
type LocationDatum struct {
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
Geocodes []Geocode `json:"geocodes"`
|
Geocodes []*Geocode `json:"geocodes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Geocode struct {
|
type Geocode struct {
|
||||||
|
Reference in New Issue
Block a user