According to these definitions,
「ちゃ‐や【茶屋】」 の意味とは - Yahoo!辞書
3 江戸時代、上方の遊里で、客に芸者・遊女を呼んで遊ばせ た家。揚屋(あげや)より格が低かった。
4 江戸時代、江戸新吉原で、客を遊女屋などに案内することを業とした 家。引手茶屋。
the 茶屋 were in the
Edo period houses that introduced people to Geisha or prostitutes, or business that provided guidance to reach a brothel, etc, which is similar to something mentioned earlier.
Now, I'm not entirely familiar with older uses of 'gay' but the word has only meant 'homosexual' for a few decades. It seems likely and logical that 'the gay quarters' in the earlier part of the century could have referred to either or both of an area with an active nightlife (similar to 'gay paris', always prounced 'gay pah-ree' in that phrase of course), or without much of a stretch from there, to refer to the red light (brothel) district. I rather think that in many cases there's quite a bit of overlap anyway.
Take note of this from dictionary.com, which doesn't specifically address 'gay quarters' as a phrase, but supports this interpretation:
Gay | Define Gay at Dictionary.com
Usage note
In addition to its original and continuing senses of "merry, lively" and "bright or showy," gay has had various senses dealing with sexual conduct since the 17th century. A gay woman was a prostitute, a gay man a womanizer, a gay house a brothel. This sexual world included homosexuals too, and gay as an adjective meaning "homosexual" may go back to the late 1930s