From f97f51918157b871bb84e6a01b6342e0ff458b1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 25 Sep 2020 11:23:40 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E5=BE=B7=E8=BF=94=E5=9B=9E=E7=9B=B4?= =?UTF-8?q?=E8=BE=96=E5=B8=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/autonavi/autonavi.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platformapi/autonavi/autonavi.go b/platformapi/autonavi/autonavi.go index 97d3df5c..3c6b1395 100644 --- a/platformapi/autonavi/autonavi.go +++ b/platformapi/autonavi/autonavi.go @@ -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