This commit is contained in:
suyl
2021-05-11 16:20:58 +08:00
parent 4d08df34f0
commit 577c3e4b48

View File

@@ -100,8 +100,21 @@ func (a *API) GetCoordinateFromAddressByPageAll(address string, cityCode int) (g
getCoordinateFromAddressByPageAllResult.Lng = utils.Str2Float64(strs[0])
getCoordinateFromAddressByPageAllResult.Lat = utils.Str2Float64(strs[1])
}
getCoordinateFromAddressByPageAllResult.CityName = result["pois"].([]interface{})[0].(map[string]interface{})["cityname"].(string)
getCoordinateFromAddressByPageAllResult.AdName = result["pois"].([]interface{})[0].(map[string]interface{})["adname"].(string)
for _, v := range result["pois"].([]interface{}) {
if getCoordinateFromAddressByPageAllResult.CityName == "" {
if str, ok := v.(map[string]interface{})["cityname"].(string); ok {
getCoordinateFromAddressByPageAllResult.CityName = str
}
}
if getCoordinateFromAddressByPageAllResult.AdName == "" {
if str, ok := v.(map[string]interface{})["adname"].(string); ok {
getCoordinateFromAddressByPageAllResult.AdName = str
}
}
if getCoordinateFromAddressByPageAllResult.CityName != "" && getCoordinateFromAddressByPageAllResult.AdName != "" {
break
}
}
}
}