aa
This commit is contained in:
@@ -425,6 +425,30 @@ func (a *API) GetCoordinateFromAddress(address string, cityInfo string) (lng, la
|
||||
return lng, lat, 0
|
||||
}
|
||||
|
||||
func (a *API) GetCoordinateFromAddressAll(address string, cityInfo string) (getCoordinateFromAddressByPageAllResult *GetCoordinateFromAddressByPageAllResult, err error) {
|
||||
params := map[string]interface{}{
|
||||
"address": address,
|
||||
}
|
||||
if cityInfo != "" {
|
||||
params["city"] = cityInfo
|
||||
}
|
||||
|
||||
result, err := a.AccessAPI("geocode/geo", params)
|
||||
if err == nil {
|
||||
if geocodes, ok := result["geocodes"].([]interface{}); ok && len(geocodes) > 0 {
|
||||
geocode := geocodes[0].(map[string]interface{})
|
||||
locationList := strings.Split(utils.Interface2String(geocode["location"]), ",")
|
||||
if len(locationList) > 1 {
|
||||
getCoordinateFromAddressByPageAllResult.Lng = utils.Str2Float64WithDefault(locationList[0], 0)
|
||||
getCoordinateFromAddressByPageAllResult.Lat = utils.Str2Float64WithDefault(locationList[1], 0)
|
||||
}
|
||||
getCoordinateFromAddressByPageAllResult.CityName = geocode["city"].(string)
|
||||
getCoordinateFromAddressByPageAllResult.AdName = geocode["district"].(string)
|
||||
}
|
||||
}
|
||||
return getCoordinateFromAddressByPageAllResult, err
|
||||
}
|
||||
|
||||
func (a *API) GeoCodeRegeo(coords []*Coordinate, radius int, isExt bool, poiTypes []string, roadLevel, homeOrCorp int) (coordInfoList []*RegeoCodeInfo, err error) {
|
||||
coordStrList := make([]string, len(coords))
|
||||
for k, v := range coords {
|
||||
|
||||
@@ -86,7 +86,7 @@ func TestGetDistricts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCoordinateFromAddress(t *testing.T) {
|
||||
lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("兴月宏干杂", "成都")
|
||||
lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("重庆市渝北区龙山大道111号“龙湖紫都城”", "重庆市")
|
||||
t.Logf("lng:%f, lat:%f, districtCode:%d", lng, lat, districtCode)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user