Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a website that when finished will allow the user to turn on and off a number of different KML layers using checkboxes, the layers are parsed through geoXML3 and I want to know how to control the order which the layers appear.

Currently if I have 2 polygon layers (layer A and B) and I click the checkbox to load layer A then I click the checkbox to load layer B layer B will be on top as it should be. However if I then uncheck both boxes, and select B first and then A, B is still drawn on top.

I assume this is because I parse the data only the first time the boxes are checked and afterwards I just show or hide them, but is there a way to manage which layer is on top?

Below is an example of the function I use to parse the layer and then turn it on or off.

function boundaryToggle_FOS() {
if (boundaryIsLoaded_FOS == 0)
boundaryIsLoaded_FOS = 1;
    if (firstLoadFOS == 0)
        firstLoadFOS = 1;
    boundaryIsLoaded_FOS = 0;
share|improve this question

In this example KML is coming from Fusion Tables

        function changeLayer(tableidselections) {

if (tableidselections == 1265695){
     if (document.getElementById("layer").checked == true) {
       if(layer.getMap() == null) { layer.setMap(map); }

     if (document.getElementById("layer").checked == false) {
         layer.setMap(null); /*layersetoff*/

if (tableidselections == 1261953){
     if (document.getElementById("layer2").checked == true) {
       if(layer2.getMap() == null) { layer2.setMap(map); }

     if (document.getElementById("layer2").checked == false) {
         layer2.setMap(null);  /*layersetoff*/

if both layers are on - layer1 is at the bottom then layer2 on top.

share|improve this answer
Hi, thanks for the suggestion but the problem with that solution is that it requires me to upload my data to Google's servers which I would not be able to do. This was also the reason behind using GeoXML3, to parse the KML's locally so they would not need to be sent to Google. – The Silent Cartographer Jun 18 '12 at 18:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.