/************************************************************************** ** Projet : TOURS ** Nom du fichier : tours.inc.js ** Créé le : 06/11/2006 Par : JRY ** Contenu : Fichier contenant les fonctions de gestion des outils de sélection sur la carte ** ** ** Modifications : ** numéro : auteur : date : objet : le : ** ** ***************************************************************************/ function getXhrRetourn(){ if(window.XMLHttpRequest) // Firefox et autres xhrRedraw = new XMLHttpRequest(); else if(window.ActiveXObject){ // Internet Explorer try { xhrRedraw = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { xhrRedraw = new ActiveXObject("Microsoft.XMLHTTP"); } } else { // XMLHttpRequest non supporté par le navigateur alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); xhrRedraw = false; } return xhrRedraw; } function removeLayerClass(){ if(document.getElementById('idListeCouche').value == ""){ alert('Vous devez choisir un theme ') ; return ; } activeLayer = new Array() ; var tbl = document.getElementById('tableClassModif') ; aInput = tbl.getElementsByTagName("input"); for(i=0;i 0){ var idLayer = document.getElementById('idListeCouche').value ; xhrGo2Zoom = getXhrRetourn(); xhrGo2Zoom.onreadystatechange = function(){ if(xhrGo2Zoom.readyState == 4 && xhrGo2Zoom.status == 200){ } } xhrGo2Zoom.open("GET","ajax.adminmap.php?supprClass=ok&idLayer="+idLayer+"&class="+activeLayer); xhrGo2Zoom.send(null); } } function zoomQuartier(paramId){ if(paramId != ""){ parURL = 'drawMap.php?carte_state=zoomQuartier&idQuartier='+paramId; redrawMap(parURL); } } function getRootPath() { var theLoc = document.location.href; var theLastPos = theLoc.lastIndexOf('/'); var RootPath = theLoc.substr(0,theLastPos) + '/'; return RootPath; } function print_r(tableau){ strMsg = 'array(' ; /*for(i=0;i < tableau.length;i++){ strMsg += "\t"+tableau[i]+"\n" ; } strMsg = 'array)\n' ;*/ alert(strMsg) ; } function setCursor() { var internalCursor = ((navigator.version < 6) && (navigator.appName == 'Netscape')); var usedCursor = 'default'; var rootPath = getRootPath(); //document.getElementById('visualisation').style.cursor = usedCursor; switch (carte_state) { case "zoomin" : usedCursor = (internalCursor) ? 'crosshair' : 'url(' +rootPath + zoominCursor+')'; break; case "zoomout" : usedCursor = (internalCursor) ? 'e-resize' : 'url(' +rootPath + zoomoutCursor+')'; break; case "zoompan" : usedCursor = (internalCursor) ? 'move' : 'url(' +rootPath + panCursor+')'; break; case "info" : usedCursor = (internalCursor) ? 'default' : 'url('+rootPath + queryCursor+')'; break; case "seldot" : usedCursor = (internalCursor) ? 'default' : 'url(' +rootPath + dotselCursor+')'; break; case "polysel" : usedCursor = (internalCursor) ? 'crosshair' : 'url('+rootPath + polyselCursor+')'; break; case "searchZU" : usedCursor = (internalCursor) ? 'default' : 'url('+rootPath + queryCursor+')'; break; case "searchZaU" : usedCursor = (internalCursor) ? 'default' : 'url('+rootPath + queryCursor+')'; break; } document.getElementById('visualisation').style.cursor = usedCursor; } function changeTypeCursor(tag,cursorType){ visu = document.getElementById(tag); visu.style.cursor = cursorType; } function setModeState(parstate){ carte_state = parstate ; vectLayer.initPoly(); if(carte_state == "zoompan") { setCursor(); changeTypeCursor('cadreVide','move'); } else if(carte_state == "zoomin" || carte_state== "zoomout") { setCursor(); //visu = document.getElementById("mapImg"); //visu.className=""; //document.getElementById('visualisation').style.cursor = "pointer"; } else if(carte_state == "fullextent"){ parURL = 'drawMap.php?carte_state='+carte_state; visualisationDiv = document.getElementById('visualisation'); carteClick(visualisationDiv,false); changeTypeCursor('visualisation','default'); redrawMap(parURL); } else if(carte_state == "measure" || carte_state == "line"){ changeTypeCursor('visualisation','crosshair'); } else if(carte_state == "print"){ changeTypeCursor('visualisation','default'); } else if(carte_state == "zoompan" || carte_state == "seldot" || carte_state == "polysel" || carte_state == "info" || carte_state == "searchZU" || carte_state == "searchZaU"){ setCursor(); } } function navCurrent(nomNav,iCur,nbreNav) { for(nav=1;nav<=nbreNav;nav++){ cur = document.getElementById(nomNav+nav); if (iCur == nav) cur.className="current"; else cur.className=""; } } function showDivPrincipal(nomDiv, mode){ if(cibleClass = document.getElementById(nomDiv)) { cibleClass.style.display = mode ; if(mode != 'none') nomDiv.className = "current"; } } function TabClick(nTab){ showDivPrincipal('ctrlTheme', 'none'); showDivPrincipal('ctrlInfo', 'none'); showDivPrincipal('ctrlOutils', 'none'); //showDivPrincipal('ctrlLegende', 'none'); showDivPrincipal('ctrlRue', 'none'); showDivPrincipal('ctrlIti', 'none'); showDivPrincipal(nTab, 'block'); } function tabClassClick(tabBlock,tabNone){ showDivPrincipal(tabNone, 'none'); showDivPrincipal(tabBlock, 'block'); } function TabAdmin(nTab){ document.getElementById('mapImg').useMap = ''; showDivPrincipal('messageErreur', 'none'); showDivPrincipal('adminvide', 'none'); showDivPrincipal('adminCreate', 'none'); showDivPrincipal('adminMove', 'none'); showDivPrincipal('adminDelete', 'none'); showDivPrincipal('adminMap', 'none'); showDivPrincipal(nTab, 'block'); } function MapAdmin(nTab){ showDivPrincipal('editionLayerAdmin', 'none'); showDivPrincipal('editionMapAdmin', 'none'); showDivPrincipal(nTab, 'block'); } function id2Elt(id) { if (document.getElementById) { leDiv = document.getElementById(id); } else if (document.all) { leDiv = eval("document.all." + id); } return leDiv; } /************************************************************************************************************** function pour gerer le cadre pour le zoom a une echelle predefini **************************************************************************************************************/ function goforbox(num){ // // var scalstand = new Array(250000, 100000, 40000, 25000, 17500, 12500, 7500, 3000); var valechelle = echelleCur * 3; cartex = getLeft(visualisationDiv);//parseInt(visualisationDiv.offsetLeft); cartey = getTop(visualisationDiv);//parseInt(visualisationDiv.offsetTop) ; cartew = parseInt(visualisationDiv.style.width); carteh = parseInt(visualisationDiv.style.height); var delta = Math.abs(scalstand[0]-valechelle); var EchProx = scalstand[0]; $nb=1; for (icount=1; icount < scalstand.length+1; icount++) { if(Math.abs(scalstand[icount]-valechelle) < delta){ delta = Math.abs(scalstand[icount]-valechelle); EchProx = scalstand[icount]; $nb = icount+1; } } if(num < EchProx){ for (icount=0; icount < scalstand.length+1; icount++){ if(EchProx == scalstand[icount]){ vallargeur = (Larg*num)/EchProx; valhauteur = (haut*num)/EchProx; valleft = cartex+((cartew-vallargeur)/2); valtop = cartey+((carteh-valhauteur)/2); //alert(num+"<"+EchProx+"="+scalstand[icount]); } } cibleClass = document.getElementById("zoomboxSlide"); cibleClass.style.display = "block"; cibleClass.style.width = vallargeur+"px"; cibleClass.style.height = valhauteur+"px"; cibleClass.style.left =valleft+"px"; cibleClass.style.top =valtop+"px"; } //alert(num+"-----"+EchProx+"fsdfs"+echelleCur+"val"+valechelle); } function setSlide(parscale){ parURL = 'drawMap.php?carte_state=zoomScale&val_scale='+parscale; //document.getElementById('mapImg').src="images/loading.gif"; //twAller(parURL) ; redrawMap(parURL); } function validateSlide(iCur){ for(iI = 1 ; iI < 9 ; iI++){ sld = document.getElementById("zoom"+iI); if (iCur == iI)sld.className="current"; else sld.className=""; } } function showDivZoom( mode){ if(cibleClass = document.getElementById("zoomboxSlide"))cibleClass.style.display = mode ; else alert('div '+nomDiv+ 'not found'); } var xhrRedrawMap = null ; function setInfosBull(){ bInfo = false ; return ; } function redrawMap(parurl){ //twAller(parurl) ; //return ; document.getElementById('divWait').style.display = "block"; xhrRedrawMap = getXhrRetourn(); xhrRedrawMap.onreadystatechange = function(){ if(xhrRedrawMap.readyState == 4){ if(xhrRedrawMap.status == 200){ try{ var reponse = new Array(); var str = xhrRedrawMap.responseText; reponse = str.split('@@'); if(reponse[0] != "" && reponse[0] != null )eval(reponse[0]); strimage = reponse[1]; if (strimage != 'erreur' && strimage != 'non_dessin'){ var imgTemp = new Image(); imgTemp.src = strimage; imgTemp.onload = function () { visualisationDiv = document.getElementById('visualisation'); selectionDiv = document.getElementById('cadreVide'); document.getElementById('mapImg').src = this.src; selectionDiv.style.display = "none" ; visualisationDiv.style.display = "block" ; carteClick(visualisationDiv,true); carteClick(selectionDiv,true); document.getElementById('divWait').style.display = "none"; if(echelleCur){ if(document.getElementById("admin1").className == "current")document.getElementById('admin1').onclick(); else if(document.getElementById("admin2").className == "current"){ document.getElementById('admin2').onclick(); setModeState('avantDepl'); } else if(document.getElementById("admin3").className == "current"){ document.getElementById('admin3').onclick(); setModeState('avantSuppr'); } else if(document.getElementById("admin4").className == "current")document.getElementById('admin4').onclick(); } }; } else{ document.getElementById('divWait').style.display = "none"; } bActionCur = 0 ; if(carte_state == 'zoomref')carte_state = 'zoomin'; } catch(e){ document.getElementById('divWait').style.display = "none"; } } } } xhrRedrawMap.open("GET",parurl,true); xhrRedrawMap.send(null); } function redrawMapSlide(parurl) { document.getElementById('divWait').style.display = "block"; xhrRedrawMapSlide = getXhrRetourn(); xhrRedrawMapSlide.onreadystatechange = function(){ if(xhrRedrawMapSlide.readyState == 4 && xhrRedrawMapSlide.status == 200){ var reponse = new Array(); var str = xhrRedrawMapSlide.responseText; reponse = str.split('@@'); if(reponse[0] != "")eval(reponse[0]); strimage = reponse[1]; if (strimage != 'erreur' && strimage != 'non_dessin'){ var tempImg = new Image(); tempImg.src = strimage ; tempImg.onload = function manajavona(){ leDivImage = document.getElementById('mapImg'); selectionDiv = document.getElementById('cadreVide'); leDivImage.title = ""; divImageSel = document.getElementById("mapImgSel"); visualisationDiv = document.getElementById('visualisation'); leDivImage.src = "images/dot.gif"; //invisible(); crossfade(leDivImage,tempImg,2); displayDivImg() ; document.getElementById('divWait').style.display = "none"; cartepantop = 0; cartepanleft = 0; carteClick(visualisationDiv,true); carteClick(selectionDiv,true); } } bActionCur = 0 ; } } xhrRedrawMapSlide.open("GET",parurl,true); xhrRedrawMapSlide.send(null); } function infoBulleDisplay(parURL,parX,parY){ xhrInfoBulle = getXhrRetourn(); xhrInfoBulle.onreadystatechange = function(){ if(xhrInfoBulle.readyState == 4 && xhrInfoBulle.status == 200){ var str = xhrInfoBulle.responseText; if(str!=''){ if(bInfo == true){ if(mousEvent[0] < 567 || mousEvent[1] < 452){ setInfoCursor(); toolTipStat(str,parX,parY); //toolTipStat(str,mousEvent[0],mousEvent[1]); } } } } } xhrInfoBulle.open("GET",parURL,true); xhrInfoBulle.send(null); } function displayDivImg(){ selectionDiv.style.display = "none" ; visualisationDiv.style.display = "block" ; return; } function openCadreImprim(){ openCadre_arc('cadre_imprim','Impression',120,256,230,100,'print.pop.php'); } function twAller(_url,_cadre,_target) { if (_url){ if (_cadre){ parent._cadre.location.href = _url; } else if (_target){ _target = window.open(_url,_target); } else{ window.location.href = _url; } } } function traiteRecherche(parurl,divId) { xhrTraiteRecherche = getXhrRetourn(); document.getElementById(divId).innerHTML = "chargement en cours..."; xhrTraiteRecherche.onreadystatechange = function(){ if(xhrTraiteRecherche.readyState == 4 && xhrTraiteRecherche.status == 200){ document.getElementById(divId).innerHTML = xhrTraiteRecherche.responseText; } } xhrTraiteRecherche.open("GET",parurl,true); xhrTraiteRecherche.send(null); } function searchList(idObj){ var strSearch = document.getElementById(idObj).value; var reg_search = /^ {1,}| {1,}$/g; strSearch = strSearch.replace(reg_search,""); if (strSearch.length > 1) { TabClick('ctrlInfo'); controlCurrent(2); var nav = (navigator.appName == 'Netscape')? "netscape" : "ie"; traiteRecherche('recherche.php?motCle='+strSearch+"&nav="+nav,'ctrlInfo'); }else alert("Saisissez au moins deux lettres"); } function controlCurrent(iCur) { for(nav=1;nav<5;nav++){ cur = document.getElementById("control"+nav); if (iCur == nav) cur.className="current"; else cur.className=""; } } function showContenuUL(code, limite){ obj = document.getElementById(code) ; objIm = document.getElementById(code+"image") ; leStyle = obj.style ; if(leStyle.display == "block") { leStyle.display = "none"; if(objIm) { if(/bottom/.test(objIm.src)) objIm.src = "images/plusbottom.gif" ; else objIm.src = "images/plus.gif" ; } }else{ leStyle.display = "block" ; if(objIm) { if(/bottom/.test(objIm.src)) objIm.src = "images/minusbottom.gif" ; else objIm.src = "images/moins.gif" ; } } } function showContenuULsanslimite(code) { obj = document.getElementById(code) ; leStyle = obj.style ; if(leStyle.display == "block"){ leStyle.display = "none" ; }else{ leStyle.display = "block" ; } } function showContenuULSpecifique(code, paramDisplay){ obj = document.getElementById(code) ; objIm = document.getElementById(code+"image") ; leStyle = obj.style ; leStyle.display = paramDisplay ; if(paramDisplay=='none' && objIm)objIm.src = "images/plus.gif" ; else if(paramDisplay=='block' && objIm)objIm.src = "images/moins.gif" ; } function showAllLayer(paramNombreLayer,paramDisplay){ for(iNav=0;iNav