1

I would like to have my map cycle through the display of loaded overlays and base layers using JavaScript or jQuery. I would like to do this with a delay of 5 seconds between cycling.

Does anyone have any idea on how to do this?

1

Since you are a student, I will not give you the complete code, however here is a a way to do it:

var totallayers;
totallayers = map.layers.length;

gives you the total number of visible layers

So, simply get the Total Number of Layers as above then use a JavaScript Timer to call a function that increments the current layer counter, resets it to zero when it reaches the total layers you have, then hide the previously displayed layer and show the next one using:

 function showhidelayer(){

   //handle your counters here

   map.getLayersByName(map.layers[layertohide].name)[0].setVisibility(false);
   map.getLayersByName(map.layers[layertoshow].name)[0].setVisibility(true);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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