增加地址解析
This commit is contained in:
@@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,7 +65,7 @@ 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