美团配送,高德
This commit is contained in:
@@ -504,6 +504,17 @@ func (a *API) GetCoordinateTownInfo(lng, lat float64) (townName, townCode string
|
||||
return townName, townCode
|
||||
}
|
||||
|
||||
func (a *API) GetCoordinateCityInfo(lng, lat float64) (cityName, cityCode string) {
|
||||
result, err := a.GetCoordinateAreaInfo(lng, lat)
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||
if err == nil {
|
||||
addressComponent := result["regeocode"].(map[string]interface{})["addressComponent"].(map[string]interface{})
|
||||
cityName = utils.Interface2String(addressComponent["city"])
|
||||
cityCode = utils.Interface2String(addressComponent["citycode"])
|
||||
}
|
||||
return cityName, cityCode
|
||||
}
|
||||
|
||||
// 这里的District指的是地点,不是实际上的区,具体级别看level
|
||||
// 这个函数返回的可能不是同级别的地点
|
||||
func (a *API) GetDistricts(subDistrict int, keywords string) (districtList []*District, err error) {
|
||||
|
||||
@@ -85,7 +85,7 @@ func TestGetDistricts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCoordinateFromAddress(t *testing.T) {
|
||||
lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("四川成都市武侯区城区天府三街与云华路交汇处大有智慧2栋1单元1101号", "")
|
||||
lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("河北廊坊市三河市燕郊镇燕郊经济开发区迎宾北路燕京理工学院", "")
|
||||
t.Logf("lng:%f, lat:%f, districtCode:%d", lng, lat, districtCode)
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func TestBatchWalkingDistance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAA(t *testing.T) {
|
||||
result, err := autonaviAPI.GetCoordinateAreaInfo(123.450477, 41.737170)
|
||||
result, err := autonaviAPI.GetCoordinateAreaInfo(118.932092, 32.112661)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user