At the simplest level, they both had a sense of the basic goodness of man uncomplicated by the artifical structures of society.
Rousseau noted that the richer and more sophisticated we became, the more we depended on luxuries and "needs" that gave birth to structures that separated us rather than brought us together. We were better off in the simpler state where we ate when we were hungry and only what we needed, picking fruit or hunting only what we could eat, not what we could acquire. This state of nature was morally superior to the state of civilization that Rousseau saw around him.
Whitman had a similar vision of the unity of all man, each of us begin a "leaf of grass," some taller, some greener, but all an extension of the same spirit; you can see the germ of this idea in Emerson's Oversoul and many of his other writings. Whitman's endless catalogues of the Democratic ideal places slaves, Indians, gays, straights --- everyone in the same grammatical structure because he saw them as essentially the same separated, again, only by artifical social structures and beliefs.
This common belief in the basic goodness of man when separated from society, when joined with nature and each other, is a central concept of Rousseau, Whitman and the Romantics.