<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi everyone.<br>
<br>
I'm trying to do a 2 in 1 action with Cartoweb: Show some layers in a
special order. So it means i have to check some layers in the layers
tree and reorder them. Finally i make the ajax call to make Cartoweb
apply the changes.<br>
<br>
The problem is Cartoweb seems not to know the layers i just checked.
Here's the error message.<br>
<pre>version: 3.3.0 [$Revision: 1.2 $]
class: CartocommonException
message: Error [8, Undefined index: 1, /opt/cartoweb/cartoweb3/projects/aeag/plugins/layerReorder/client/ClientLayerReorder.php, 478]
</pre>
<br>
So here's the function i made to do this.<br>
<br>
<blockquote><i>function chargeVue() { </i><br>
<i> <font color="#009900">// Here i get the layers i need to show
in a field of my form</font></i><br>
<i> for (var i=0; i<$('selectVue').options.length; i++) {</i><br>
<i> if ($('selectVue').options[i].selected ) {</i><br>
<i> selectione = $('selectVue').options[i].value;</i><br>
<i> }</i><br>
<i> } </i><br>
<i> </i><br>
<i> <font color="#009900">// Here i check the layers i got in the
layer tree</font></i><br>
<i> var tabSel = $('vue_'+selectione).value.split(";");</i><br>
<i> var tabOrdre = new Array();</i><br>
<i> var celts = $('layersroot').getElementsByTagName('input');</i><br>
<br>
<i> for (var j = 0; j < celts.length; j++) {</i><br>
<i> if (!celts[j].checked &&
inArray(tabSel,celts[j].value)) {</i><br>
<i> celts[j].checked = true;</i><br>
<i><font color="#009900"> // Here i store the order of the
layers in the layers tree</font></i><br>
<i> tabOrdre.push(celts[j].value);</i><br>
<i> }else</i><br>
<i> celts[j].checked = false;</i><br>
<i> }</i><br>
<i> </i><br>
<i> <font color="#009900">// Here i fill an array with the new
layers order</font></i><br>
<i> var tabNewOrdre = new Array();</i><br>
<i> for (j = 0; j < tabSel.length; j++) {</i><br>
<i> // Ajoute l'indice de la couche dans tabOrdre</i><br>
<i> tabNewOrdre.push(indexInArray(tabOrdre,tabSel[j]));</i><br>
<i> }</i><br>
<i> $('layersReorder').value = tabNewOrdre.join(",");</i><br>
<i> </i><br>
<i> <font color="#009900">// Here i update the map</font></i><br>
<i> CartoWeb.trigger('Layers.LayerShowHide');</i><br>
<i>}</i><span class="sourceRowText"></span><br>
<span class="sourceRowText"></span></blockquote>
<br>
<br>
<br>
<b>Is there a way to achieve this without making 2 ajax calls (one to
check the layers, the other to order them)?<br>
<br>
</b>Thanks for your help<br>
<br>
Simon Ortet<br>
Silogic<br>
</body>
</html>