Title: Working workaround to set a zIndex KmlLayer
Tags: javascript;google-maps;google-maps-api-3;z-index;settimeout
Question: I've been searching for a straight solution to a problem I have since a couple of days.
For example , you need to add multiple kml layers on a map, in a specific order, then you need zIndex.
But with Google Maps API V3, you don't have such things.
Any idea?
Comment: I just edited my post. The anwer will come later.

Comment: What you need to do is re-format this whole thing.  Post just what's required to be a Question here.  Then post a separate Answer that solves the problem.

Here is the accepted answer: So two things you can do.
First workaround is to add listeners:
https://gist.github.com/jkeefe/1170104
Second workaround is to set timeouts between calls.
It will not take long to load a layer on a map.
In fact, not more than 10 milliseconds is necessary.
Simply add setTimeout inside the callback function of a setTimeout.
Example:
layers.setMap(map);
setTimeout(function(){
layers2.setMap(map);
setTimeout(function(){
layers3.setMap(map);
setTimeout(function(){
layers4.setMap(map);
setTimeout(function(){
layers5.setMap(map);
},400);
},100);
},100);
},100);
I used the second workaround.
If you think this thread is helpfull, then make me know,
Comment for this answer: This won't guarantee layer order (although it will be correct most of the time).

Here is another answer: The only way to guarantee order for Kml layers is to wait for previous layers to draw before adding the next layer. You listen to the metadata_changed event to know when a layer has drawn.
A z-index option is a highly requested feature: https://code.google.com/p/gmaps-api-issues/issues/detail?id=2804
Comment for this answer: has z-index been implemeneted yet?

Here is another answer: The Google Maps Javascript API v3 KmlLayerOptions now includes zIndex.
From the (latest) documentation:
zIndex | Type:  number
The z-index of the layer.
(or you can use the setZIndex method)
See example in this related question: KML ordering in Google Maps API
proof of concept fiddle

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2013:00:12/31/13', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<javascript><google-maps><google-maps-api-3><z-index><settimeout>', 'Title': 'Working workaround to set a zIndex KmlLayer', 'ViewCount': 1327, 'id': 20858633, 'user_AboutMe': '<p>test de compte</p>\n', 'user_AccountId': 2481560.0, 'user_DisplayName': 'bug', 'user_Reputation': 342.0, 'user_Views': 35.0, 'user_id': 2160937.0}}