高德返回直辖市
This commit is contained in:
@@ -509,7 +509,13 @@ func (a *API) GetCoordinateCityInfo(lng, lat float64) (cityName, cityCode string
|
|||||||
// baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
// baseapi.SugarLogger.Debug(utils.Format4Output(result, false))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
addressComponent := result["regeocode"].(map[string]interface{})["addressComponent"].(map[string]interface{})
|
addressComponent := result["regeocode"].(map[string]interface{})["addressComponent"].(map[string]interface{})
|
||||||
cityName = utils.Interface2String(addressComponent["city"])
|
if addressComponent["city"] != nil {
|
||||||
|
if cn, ok := addressComponent["city"].(string); ok {
|
||||||
|
cityName = cn
|
||||||
|
} else {
|
||||||
|
cityName = utils.Interface2String(addressComponent["province"])
|
||||||
|
}
|
||||||
|
}
|
||||||
cityCode = utils.Interface2String(addressComponent["citycode"])
|
cityCode = utils.Interface2String(addressComponent["citycode"])
|
||||||
}
|
}
|
||||||
return cityName, cityCode
|
return cityName, cityCode
|
||||||
|
|||||||
Reference in New Issue
Block a user