This is somewhat similar to the question asked here --
I\'m writing a search box for a map application, which retrieves a whole set of search results (people\'s name
Regarding the last part of your question, if you want to iterate through visible layers, you can use eachLayer, e.g:
map.eachLayer(function (layer) { // do something with the layer });
API reference: http://leafletjs.com/reference.html#map-stuff-methods