高德返回直辖市

This commit is contained in:
苏尹岚
2020-09-25 11:23:40 +08:00
parent c7f38d6fc8
commit f97f519181

View File

@@ -509,7 +509,13 @@ func (a *API) GetCoordinateCityInfo(lng, lat float64) (cityName, cityCode string
// 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"])
if addressComponent["city"] != nil {
if cn, ok := addressComponent["city"].(string); ok {
cityName = cn
} else {
cityName = utils.Interface2String(addressComponent["province"])
}
}
cityCode = utils.Interface2String(addressComponent["citycode"])
}
return cityName, cityCode