
<!-- **************************************************************** -->
<!-- *************    Script de navigation sur la carte ************* -->
<!-- **************************************************************** -->
function Point(x,y){this.x=x;this.y=y;}
function Rectangle(x,y,width,height){this.x=x;this.y=y;this.width=width;this.height=height}
var mouseisdown = 0;
var ptDepart;
var ptCourant = new Point(0,0);
var xmlFileSRC = "";
var isloading = false;

<!-- ----------------------------------------------------------------- -->
<!-- ------ Mise à jour de la variable curTool sur les plugin -------- -->
<!-- ----------------------------------------------------------------- -->
function UpdateToolPlugins()
{
if(szFormat=="4")//format Flash
{
var objFlash = document.getElementById("IMG");
if(objFlash!=null)
{
var strCurTool = "" + curTool;
objFlash.SetVariable('curTool',strCurTool);
}
}

}

<!-- ----------------------------------------------------------------- -->
<!-- -------------   Redessine la carte courante ------------------ -->
<!-- ----------------------------------------------------------------- -->
function RedrawMap()
{

var i = 0;
var loc = location.href;
var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" +  (maptop - mapbottom) + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;
			
	updateBufferMap(chaine);

}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   Selectionne l'outil zoom moins ------------------ -->
<!-- ----------------------------------------------------------------- -->
function SetToolZoomPlus()
{
 if(szdrawMode==1)
                drawMode();
 curTool = 209;
 var obj = document.getElementById("divMap");
	obj.style.cursor = "crosshair";
	UpdateToolPlugins();


}

function clickZoomPlus()
{
	 if(szdrawMode==1)
                drawMode();
 //curTool = -1;
	var obj = document.getElementById("divMap");
	obj.style.cursor = "crosshair";
	var loc = location.href;
	UpdateToolPlugins();
	  var newtop;
		var newleft;
		var newwidth;
		var newheight;
		var loc = location.href;
		newwidth = (mapright - mapleft)/2;
	  newheight = (maptop - mapbottom)/2;
		newbottom = (maptop+mapbottom)/2 - newheight/2;
		newleft = (mapright+mapleft)/2 - newwidth/2;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   Selectionne l'outil zoom plus  ------------------ -->
<!-- ----------------------------------------------------------------- -->
function SetToolZoomMoins()
{
 if(szdrawMode==1)
                drawMode();
 curTool = 210;
var obj = document.getElementById("divMap");
	obj.style.cursor = "crosshair";
	var loc = location.href;
	UpdateToolPlugins();
	  var newtop;
		var newleft;
		var newwidth;
		var newheight;
		var loc = location.href;
		newwidth = (mapright - mapleft)*2;
	  newheight = (maptop - mapbottom)*2;
		newbottom = (maptop+mapbottom)/2 - newheight/2;
		newleft = (mapright+mapleft)/2 - newwidth/2;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
	
	
								if(editSvg)
								{
								
								var conf = haveTosend();
								if(conf==true)
								{
								
								 var chaineSvg = szHttpServeur  +
								 "&ACTION=EditLayer!NAME="+currentEditedLayer+"!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +"!LOCATION=" + loc + "!LAYER_EDITION";
								 updateBufferEditLayer(chaineSvg);
								 editSvg=true;
		
								 showObject("divEditLayer");
								 }
								 }
	
	
}

<!-- ----------------------------------------------------------------- -->
<!-- -------------   Affiche une infobulle (uniquement en IE)  ------------------ -->
<!-- ----------------------------------------------------------------- -->
function processToolTipPng(e,strToolTip)
{
 				 var obj = document.getElementById("tooltip");
				
				 if(obj!=null)
				 {
 			
				
					if(e==null)
					{
					obj.style.visibility = "hidden";
					
					return;
					}
					else
					{
					obj.style.visibility = "visible";
					}
					
						 var ptMouse = getMousePosition(e);
				
				ptMouse.x =  ptCourant.x + 30;
				ptMouse.y =  ptCourant.y + 30;
					obj.style.top = ptMouse.y;
					obj.style.left = ptMouse.x;
					
					var inner = "";
					if(strToolTip.length>0)
					{
					var tToolTip = strToolTip.split('|');
					var k = 0;
					inner = "<table>"; 
					for(k=0;k<tToolTip.length;k++)
					{				
									var ttToolTip = tToolTip[k].split(':');
									
									inner = inner + "<tr><td style=\"font-size: 10px;\">"	;							
					 				inner = inner + 		ttToolTip[0];	
									inner = inner + "</td>";
									var j=1;
									for(j=1;j<ttToolTip.length;j++)
									{
									inner = inner + "<td style=\"font-weight: bold;font-size: 10px;\">"	;		
									inner = inner + " : " +	ttToolTip[j];	
									inner = inner + "</td>";			
									}
									
									inner = inner + "</tr>";						
					}
					inner = inner + "</table>";
					}
					else
					{
					obj.style.visibility = "hidden";
					}
					
					obj.innerHTML = inner;
					}
					
}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   Selectionne l'outil est le Pan sur la map  ------------------ -->
<!-- ----------------------------------------------------------------- -->
function SetToolPan()
{
 if(szdrawMode==1)
                drawMode();
 curTool = 213;
  var obj = document.getElementById("divMap");
	obj.style.cursor = "move";
	UpdateToolPlugins();

}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   Selectionne l'outil Selection Carte ------------- -->
<!-- ----------------------------------------------------------------- -->
function SetToolSelectionCarte()
{
if(editSvg)
					alert(msgEditionInProgress)
					else
					{
 if(szdrawMode==1)
                drawMode();
 curTool = 211;
 
	 var obj = document.getElementById("divMap");
	obj.style.cursor = "help";
	UpdateToolPlugins();
	}

}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   Selectionne l'outil zoom sur objet clické ------------- -->
<!-- ----------------------------------------------------------------- -->
function SetToolZoomObjet()
{
 if(szdrawMode==1)
                drawMode();
 curTool = 212;
var obj = document.getElementById("divMap");
	obj.style.cursor = "crosshair";
	UpdateToolPlugins();

}

<!-- ----------------------------------------------------------------- -->
<!-- -------------   mise à jour de la fenetre d'echelle  ------------- -->
<!-- ----------------------------------------------------------------- -->
function SetEchelle(newEchelle)
{
	 var echelleDiv = document.getElementById('divSaisieEchelle');
	 if(echelleDiv!=null)
	 {
		echelleDiv.innerHTML = "Echelle > 1/"+ Math.round(newEchelle);
		getIScale(newEchelle);
	 }
}

<!-- ----------------------------------------------------------------- -->
<!-- -------------   mise à jour de la fenetre d'echelle en fonction de la carte ------------- -->
<!-- ----------------------------------------------------------------- -->
function GetEchelleMap()
{
	var ws = 0.0;
	var clW = 0.0;

	var wScreen = 0.0;
	var mapCenterX = 0.0;
	var mapCenterY = 0.0;
	var newwidth = 0.0;
	var newheight = 0.0;
	var curwidth = 0.0;
	ws = 1280;//window.screen.width;
	clW = mapClientwidth;

	//ecran 17 pouces
	wScreen =  (clW/ws) *(4.0/5.0)*17*2.54/100.0;
	
	curwidth = mapright-mapleft;
	SetEchelle(curwidth/wScreen);
	return(curwidth/wScreen);

}
function UpdateMousePosition(x,y)
{
}

<!-- ----------------------------------------------------------------- -->
<!-- -------------   mise à jour de la carte par saisie d'une nouvelle echelle  ------------- -->
<!-- ----------------------------------------------------------------- -->
function UpdateMapEchelle(echelle)
{
var ws = 0.0;

var clW = 0.0;

var wScreen = 0.0;
var mapCenterX = 0.0;
var mapCenterY = 0.0;
var newwidth = 0.0;
var newheight = 0.0;
var loc = location.href;
ws = 1280;//window.screen.width;

clW = mapClientwidth;

//ecran 17 pouces
wScreen =  (clW/ws) *(4.0/5.0)*17*2.54/100.0;
newwidth = wScreen*echelle;
newheight = (mapClientheight/clW)*newwidth;

mapCenterX = (mapright+mapleft)/2.0;
mapCenterY = (maptop+mapbottom)/2.0;

newleft = mapCenterX-newwidth/2.0;
newbottom = mapCenterY-newheight/2.0;


//alert("ws=" +ws+" \n" + "clW=" +clW+" \n" + "wScreen=" +wScreen+" \n" + "newwidth=" +newwidth+" \n" + "newheight=" +newheight+" \n" + "mapCenterX=" +mapCenterX+" \n" + "mapCenterY=" +mapCenterY+" \n");
var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);

}
<!----------------------------------------------------------------------->
<!-- fonction appellée par le navigateur flash au mouseMove            -->
<!----------------------------------------------------------------------->

function updateMousePosition(x,y)
{
}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   mise à jour de la carte        ------------------ -->
<!-- charge dans la frame cachée BufferMap la page HTML issu du parse  -->
<!-- serveur du flux XML, transformé par la feuille de style carte.XSL -->  
<!-- OnLoad cette frame appel loadMap pour mettre à jour le divMAP     -->       
<!-- ----------------------------------------------------------------- -->
function updateBufferMap(target) 
{
if(!isloading)
{
  isloading = true;
	showObject("divProgress");
  var movieprogress = document.getElementById('movieprogress');
	var curtime = new Date();
	
	if(szFormat=="4")
	{
	frames['bufferMap'].location.href=target+  "!SHOWECHELLE=" + szShowEchelle + "&FORMAT=" + szFormat + "&XSL=carteFlash.xsl&CURRENTTIME="+ curtime.getTime() +"&PORT=" + szPort;  
	}
	else
	{
	frames['bufferMap'].location.href=target+  "!SHOWECHELLE=" + szShowEchelle + "&FORMAT=" + szFormat + "&CURRENTTIME="+ curtime.getTime() + "&PORT=" + szPort; 
	}
	/*if(movieprogress!= null)
	{
	movieprogress.rewind();
	movieprogress.play();
	}*/
	if(movieprogress!= null)
	{
		try
		{
			movieprogress.rewind();
			movieprogress.play();
		}
		catch ( error )
		{
			
		}
	
			
	}
	}
}
function FlashLoaded()
{
UpdateToolPlugins();
}

function loadEchelle()
{
	if(frames['bufferMap'].document.getElementById('buffEchelle')!=null)
	{
		if(document.getElementById('divEchelle')!=null)
		{
			document.getElementById('divEchelle').innerHTML = frames['bufferMap'].document.getElementById('buffEchelle').innerHTML;
		}
	}
}

function loadMap() 
{
	hideObject("divProgress");
    hideObject("divBubble");
    var divMap = document.getElementById('divMap');
	isloading = false;
 	if(needNewMap == true)
	{
		if(szFormat=="4")
		{
			if(xmlFileSRC!="")
  			{
				var fo = new FlashObject("canvas.swf", "IMG", mapClientwidth, mapClientheight, "7", "#FFFFFF");
				fo.addVariable("xmlFile", xmlFileSRC); // this is always optional, but this example uses the variable and displays this text inside the flash movie
				fo.addParam("salign","LT");
				fo.addParam("swLiveConnect","true");
				fo.addParam("WMode","transparent");
				fo.write("divMap");
				loadEchelle();
				var objDivEdit = document.getElementById("divEditLayer");
				var objDivMap = document.getElementById("divMap");
				//objDivEdit.style.left = objDivMap.offsetLeft+2;
						//objDivEdit.style.top = objDivMap.offsetTop+2;	
			}
		}
		else
		{
			divMap.innerHTML=frames['bufferMap'].document.body.innerHTML;
			processToolTipPng(null,"");
		}
		
		document.onmousemove = null;
		GetEchelleMap();
		drawMiniRect();
	}
	else alert("Pas d'objet cartographique");
	
	if (currentProcess=="graphicSearch")
	{
		LanceRechercheGraphique();
	}
	currentProcess="";
						
}
<!-- ----------------------------------------------------------------- -->
<!-- --  Converti les coordonée ecran en coordonée system (réelle) ----- -->
<!-- ----------------------------------------------------------------- -->
function ConvertViewToSys(x,y)
{
	var bndTop;
	var bndLeft;
	var mapWidth;
	var mapHeigth;
	mapWidth = mapright-mapleft;
	var zoom;
	zoom = 0.0;
	zoom = mapClientwidth/mapWidth;
	
	if(szFormat=="4")
	{
	bndLeft = 0;
	bndTop = 0;
	}
	else
	{
        obj = document.getElementById("divMap");
     
	bndLeft =obj.offsetLeft;
        
  	bndTop = obj.offsetTop;
		}
	mapCurrentX = (x - bndLeft)/zoom + mapleft;
	//alert(mapleft);
	mapCurrentY = maptop - (y - bndTop)/zoom;

}
function GetMapEmpriseView()
{
    
        var obj = document.getElementById("divMap");
        var objimg = document.getElementById("IMG");
        var rect = new Rectangle(0,0,0,0);
		
		var bndLeft = obj.offsetLeft;
		var bndTop = obj.offsetTop;
		//spec rennes
		bndLeft = 150;
		bndTop = 80;
        rect.x = bndLeft;
        rect.y = bndTop;
				if(isMinNS4)
				{
        rect.width = objimg.clientWidth;
        rect.height = objimg.clientHeight;
				}
				else
				{
				rect.width = objimg.width;
        rect.height = objimg.height;
				}
	return(rect);
} 
<!-- ----------------------------------------------------------------- -->
<!-- -- Converti les coordonnées système en coordonnées écran    ----- -->
<!-- ----------------------------------------------------------------- -->
function ConvertSysToView(x,y)
{
	var bndTop;
	var bndLeft;
	var mapWidth;
	var mapHeigth;
	mapWidth = mapright-mapleft;
		
	var zoom;
	zoom = 0.0;
	zoom = mapClientwidth/mapWidth;
    obj = document.getElementById("divMap");
	bndLeft = obj.offsetLeft;
 	bndTop = obj.offsetTop;
    //Modif VDR
	bndLeft = 150;
	bndTop = 80;
	//Fin Modif VDR
	viewCurrentX = (x  - mapleft)*zoom + bndLeft;
	viewCurrentY = -(y  - maptop)*zoom + bndTop;
	
	mapCurrentY = maptop - (y - bndTop)/zoom;

}
<!-- ----------------------------------------------------------------- -->
<!-- ---------------- évenement souris bouge sur la carte ------------ -->
<!-- ----------------------------------------------------------------- -->
function getmousetool(e)
{

var pt= getMousePosition(e);

}
function getMousePosition(e)
{
      var pt = new Point(0,0);
      
     
        if(isMinNS4)
        {
                pt.x=e.pageX;
                pt.y=e.pageY;
        }
        else
        {
                pt.x=event.x+document.body.scrollLeft;
                pt.y=event.y+document.body.scrollTop;
        }
				if(pt.x!=0)
				{
				ptCourant.x = pt.x;
				ptCourant.y = pt.y;
				}
        return(pt);
      
}

function recenterMap(x,y)
{

var loc = location.href;
 hideObject("divRect");
   var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = y - newheight/2.0;
		newleft = x - newwidth/2.0;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
}
<!-- ----------------------------------------------------------------- -->
<!-- --- évenement souris drag sur la carte : si l'outil est zoom plus -->
<!-- dessinne un rectangle (divRect) sur la carte pour zoomer par rectangle -->
<!-- ----------------------------------------------------------------- -->

<!-- ----------------------------------------------------------------- -->
<!-- --- évenement souris commence drag sur la carte : si l'outil est zoom plus -->
<!-- stockage des coordonée pixel du début de rectangle pour le dessine du rectangle de zoom -->
<!-- ----------------------------------------------------------------- -->

<!-- -----------------------------------------------------------------  -->
<!-- --- évenement fin drag sur la carte : si l'outil est zoom plus     -->
<!-- appel de updateBufferMap avec les coordonnée de la nouvelle emprise-->
<!-- -----------------------------------------------------------------  -->


<!-- -----------------------------------------------------------------  -->
<!-- --- déplacement de la crate vers le nord														-->
<!-- -----------------------------------------------------------------  -->
function moveUp()
{
if(szFormat=="2")
{
 translateMap(0,-0.5);

}
else
{
        var loc = location.href;

 hideObject("divRect");
   var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = mapbottom+newheight/2.0;
		newleft = mapleft;
		
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

								
				
	updateBufferMap(chaine);
	}
	if(editSvg)
		translateEditedLayer(0,-0.5);
	
}

function moveNordOuest()
{
	var loc = location.href;
	hideObject("divRect");
		var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
		newheight = (maptop - mapbottom);
		newbottom = mapbottom+newheight/2.0;
		
		newleft = mapleft - newwidth/2.0;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
		
		
}

function moveNordEst()
{
	var loc = location.href;

	hideObject("divRect");
	var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = mapbottom+newheight/2.0;
		newleft = mapleft + newwidth/2.0;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

								
				
	updateBufferMap(chaine);
}

function moveSudOuest()
{
var loc = location.href;
                hideObject("divRect");
                var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	        newheight = (maptop - mapbottom);
		newbottom = mapbottom-newheight/2.0;
		newleft = mapleft - newwidth/2.0;
	
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
	
}

function moveSudEst()
{
	var loc = location.href;
                hideObject("divRect");
                var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	        newheight = (maptop - mapbottom);
		newbottom = mapbottom-newheight/2.0;
		newleft = mapleft + newwidth/2.0;
	
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);

}
<!-- -----------------------------------------------------------------  -->
<!-- --- déplacement de la crate vers le sud														-->
<!-- -----------------------------------------------------------------  -->
function moveDown()
{
if(szFormat=="2")
{
 translateMap(0,0.5);

}
else
{
                var loc = location.href;
                hideObject("divRect");
                var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	        newheight = (maptop - mapbottom);
		newbottom = mapbottom-newheight/2.0;
		newleft = mapleft;
	
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
	}
	
	if(editSvg)
		translateEditedLayer(0,0.5);
}


<!-- -----------------------------------------------------------------  -->
<!-- --- déplacement de la crate vers l''est														-->
<!-- -----------------------------------------------------------------  -->
function moveRight()
{
if(szFormat=="2")
{
 translateMap(0.5,0);

}
else
{
var loc = location.href;
 hideObject("divRect");
   var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = mapbottom;
		newleft = mapleft + newwidth/2.0;
		
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
	
}

if(editSvg)
			translateEditedLayer(0.5,0);
	
}

<!-- -----------------------------------------------------------------  -->
<!-- --- déplacement de la crate vers l''ouest														-->
<!-- -----------------------------------------------------------------  -->
function moveLeft()
{
if(szFormat=="2")
{
 translateMap(-0.5,0);

}
else
{
var loc = location.href;
 hideObject("divRect");
   var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = mapbottom;
		newleft = mapleft - newwidth/2.0;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
	}
	if(editSvg)
		translateEditedLayer(-0.5,0);
}
<!-- -----------------------------------------------------------------  -->
<!-- évenement bouton souris enfoncé sur la carte : si l'outil est zoom moins -->
<!-- -calcul la nouvelle emprise centré sur le click et dont la largeur  -->
<!-- vaut deux fois la largeur précédente (on dezoom d'un facteur 2) -  -->
<!-- appel de updateBufferMap avec les coordonnée de la nouvelle emprise-->
<!-- -----------------------------------------------------------------  -->

<!-- -----------------------------------------------------------------  -->
<!-- Recharge la carte tel que l'ensemble soit visible                  -->
<!-- -----------------------------------------------------------------  -->
function FitImage()
{
if(editSvg)
	//mode edition SVG
	{
		
		/*if(sendReq ==null || sendReq != false)
			//getEditionShapesCoordinates();
			
			mapWidth=null;
			mapHeight=null;*/
		var conf = haveTosend();
		if(conf==true)
		{
		var loc = location.href;
			var chaine = szHttpServeur  +
						"&ACTION=EditLayer!NAME="+currentEditedLayer+"!EMPRISE=ALL!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +"!LOCATION=" + loc + "!LAYER_EDITION";
			updateBufferEditLayer(chaine);
			editSvg=true;
		
			showObject("divEditLayer");
			
		
		
			var chaine = szHttpServeur +
							"&ACTION=BuildMap!EMPRISE=ALL!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc ;
			
			
			updateBufferMap(chaine);
			
		}
	
	}
	else
	{
	var loc = location.href;
	var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=ALL!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc ;

	
	updateBufferMap(chaine);
	}
	curTool = 1;
  var obj = document.getElementById("divMap");
	obj.style.cursor = "crosshair";
	UpdateToolPlugins();
	

}
<!-- -----------------------------------------------------------------  -->
<!-- Recharge la carte en effacent selection et analyse                 -->
<!-- -----------------------------------------------------------------  -->
function ClearMap()
{
	var loc = location.href;

	var chaine = szHttpServeur  +
                "&ACTION=ClearMap" + 
		"!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
		"!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
		"!LOCATION=" + loc ;	
	updateBufferMap(chaine);
	curTool = 1;
  var obj = document.getElementById("divMap");
	obj.style.cursor = "crosshair";
	UpdateToolPlugins();
}

function initCaptureEvent()
{   
  
  // capture d'événènements appuyer, relacher
   var obj = document.getElementById("IMG");

	 
	 if(isMinNS4)
						{
						obj.useMap="#Mapcoord";
						}
						else
						{
					// met en place la map des infobulle (uniquement en IE)
						obj.useMap="#Mapcoord";
						
						 }
						 
  if (document.captureEvents)
  { // pour Mozilla
       //  alert("salut");
    document.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
  }
    obj.onmousedown = startDrag;
    document.onmousemove = null;
    if(isMinNS4==1)
    {
         document.onmouseup = endDrag;
				 document.onmousedown = startDrag;
    }
    else
    {
         obj.onmouseup = endDrag;
    }
}

function startDrag(e)
{ 
     
    ptDepart = getMousePosition(e);
    // capture de l'événènement déplacement du curseur
     var obj = document.getElementById("IMG");
    if (document.captureEvents)
    { // pour Mozilla
      document.captureEvents(Event.MOUSEMOVE);
    }
    
    obj.onmousemove= moveMouse;
    
    return false; // retourne faux pour que l'explorateur ne tienne pas compte du déplacement 
}


function moveMouse(e)
{
 		var pt = getMousePosition(e);
        if (curTool == 209)
        {
        
        var w;
        var h;
        var leftRect;
        var topRect;
        
        w = Math.abs(pt.x-ptDepart.x);
        h = Math.abs(pt.y-ptDepart.y);
        var obj = document.getElementById("IMG");
        
        var emprise = GetMapEmpriseView();
               
      		if ((w>0)&&(h>0)&&(pt.x>emprise.x)&&(pt.y>emprise.y)&&(pt.x<emprise.x+emprise.width)&&(pt.y<emprise.y+emprise.height))
      		{
                    var obj=document.getElementById("divRect");
                    
                    if(pt.x > ptDepart.x)
                            leftRect = ptDepart.x;
                    else
                            leftRect = pt.x;
                    
                    if(pt.y > ptDepart.y)
                            topRect = ptDepart.y;
                    else
                            topRect = pt.y;
                            
                    obj.style.left = leftRect;
                    obj.style.top = topRect;	
                    obj.style.width = w;
                    obj.style.height = h;			
                    obj.style.border  = "1px solid #FF0000";
                    obj.style.color  = "#FF0000";
                    showObject("divRect");
      		 }
                 
        }
				else if (curTool == 213)
				{
				 		 var obj=document.getElementById("divImageMap");
						 
						 var deltax = pt.x-ptDepart.x;
						 var deltay = pt.y-ptDepart.y;
						 obj.style.left = deltax;
						 obj.style.top = deltay;
						 var emprise = GetMapEmpriseView();
						 var cliptop;
						 var clipbottom;
						 var clipleft;
						 var clipritgh;
						 
						 if(deltay>0)
						 		cliptop = 0;
						 else
								cliptop = -deltay;
								
						 if(deltax>0)
						 		clipleft = 0;
						 else
								clipleft = -deltax;
						
					//	 cliptop = emprise.y;
						// clipleft = emprise.x;
						 clipbottom = cliptop +  emprise.height-deltay;
						 clipright = clipleft +  emprise.width-deltax;
						 var strrect = "rect(" + cliptop + " " + clipright + " " + clipbottom + " " + clipleft + ")"
					//alert(strrect);
						 obj.style.clip = strrect;
						
						 
						 
				}
               
        return false;
        
}

function ApplyGetInfo(x,y)
{
var loc = location.href;
ConvertViewToSys(x,y);
	 //mapCurrentX
	  var newwidth;
	 newwidth = (mapright - mapleft);
	 var tol;
	 tol = 5*newwidth/mapClientwidth;
		var chaine = szHttpServeur +
                "&ACTION=ClickMap!POSITION=" + mapCurrentX + "@" + mapCurrentY + "@" + tol + "!LOCATION=" + loc ;
    openInfo = true;    
		updateBufferResultatClick(chaine);
}

function ApplyPanMap(x0,y0,x2,y2)
{
var loc = location.href;
 ConvertViewToSys(x0,y0);  
		 var x1 = mapCurrentX;
		 var y1 = mapCurrentY;
	 ConvertViewToSys(x2,y2);
	  var newtop;
		var newleft;
		var newwidth;
		var newheight;
		var deltax = mapCurrentX-x1;
		var deltay = mapCurrentY-y1;
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = mapbottom - deltay;
		newleft = mapleft - deltax;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
}
function ApplyZoomObject(x,y)
{
var loc = location.href;
 ConvertViewToSys(x,y);
	
		var chaine = szHttpServeur +
                "&ACTION=ZoomObjet!POSITION=" + mapCurrentX + "@" + mapCurrentY +
		"!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
		"!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
		"!LOCATION=" + loc ;		
               
		updateBufferMap(chaine);
}
function ApplyZoomMoins(x,y)
{
var loc = location.href;
 ConvertViewToSys(x,y);
	  var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft)*2;
	  newheight = (maptop - mapbottom)*2;
		newbottom = mapCurrentY - newheight/2;
		newleft = mapCurrentX - newwidth/2;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;
	updateBufferMap(chaine);
								if(editSvg)
								{
								var conf = haveTosend();
								
								if(conf==true)
								{
								
								 var chaineSvg = szHttpServeur  +
						"&ACTION=EditLayer!NAME="+currentEditedLayer+"!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +"!LOCATION=" + loc + "!LAYER_EDITION";
									updateBufferEditLayer(chaineSvg);
									editSvg=true;
									showObject("divEditLayer");
									}
								}
				

}

function UpdateViewBox(x0,y0,x1,y1)
{

  			 	 		if( x1 > x0 && y1 >y0)
                {
                        ConvertViewToSys(x0,y1);
                        newleft = mapCurrentX;
                        newbottom = mapCurrentY;
                        ConvertViewToSys(x1,y0);
                        newwidth = mapCurrentX - newleft;
                        newheight = mapCurrentY - newbottom;
                }
                else if ((x1 == x0)||(y1 == y0))
								{
								 		 		ConvertViewToSys(x0,y1);
								 		 		newwidth = (mapright - mapleft)/2;
	  										newheight = (maptop - mapbottom)/2;
		 										newbottom = mapCurrentY - newheight/2;
		  									newleft = mapCurrentX - newwidth/2;
								}
								else
                {
                        ConvertViewToSys(x1,y0);
                        newleft = mapCurrentX;
                        newbottom = mapCurrentY;
                        ConvertViewToSys(x0,y1);
                        newwidth = mapCurrentX - newleft;
                        newheight = mapCurrentY - newbottom;
                }
                 var loc = location.href;
                var chaine = szHttpServeur +
                           "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc ;
                                                
                updateBufferMap(chaine);

}
function endDrag(e)
{

        hideObject("divRect");
        var loc = location.href;
        var pt = getMousePosition(e);
        releaseCaptureEvent();
        var emprise = GetMapEmpriseView();
        if( (pt.x < emprise.x) || (pt.x > emprise.x+emprise.width) || (pt.y < emprise.y) || (pt.y > emprise.y+emprise.height) )
        return false;
                
        if (curTool == 209)
        {
              
                UpdateViewBox(ptDepart.x,ptDepart.y,pt.x,pt.y);
    
								}
        if (curTool == 210)
        {
       
			 	 ApplyZoomMoins(pt.x,pt.y);
	}
	else if (curTool == 211)
	{
	 		 ApplyGetInfo(pt.x,pt.y);
		
	}
	else if (curTool == 212)
	{
	ApplyZoomObject(pt.x,pt.y);
	}
	  if (curTool == 213)
    {
    ApplyPanMap(ptDepart.x,ptDepart.y,pt.x,pt.y);
	}
        
return false;
}
function releaseCaptureEvent()
{
 if (document.captureEvents)
  { // pour Mozilla
    document.releaseEvents(Event.MOUSEMOVE);
    document.releaseEvents(Event.MOUSEDOWN | Event.MOUSEUP);
  }
     var obj = document.getElementById("IMG");
     obj.onmousemove = null;
     
}

function ConvertViewToSysSVG(x,y)
{
	var mapWidth;
	var mapHeigth;
        var pt = new Point();
	mapWidth = mapright-mapleft;
	var zoom;
	zoom = 0.0;
	zoom = mapClientwidth/mapWidth;
     
	pt.x = x/zoom + mapleft;
	pt.y = maptop - y/zoom;

        return pt;
}
function ConvertViewToSysDistanceSVG(d)
{
	var mapWidth;
	mapWidth = mapright-mapleft;
	var zoom=0.0;
	zoom = mapClientwidth/mapWidth;
     

        return d/zoom;
}
function sendSvgRequest(req)
{
        var loc = location.href;
	var newwidth = (mapright - mapleft);
	var tol= 5*newwidth/mapClientwidth;
        
        var chaine = szHttpServeur + "&ACTION=SelectTool!SHAPES=" + req + "!TOLERANCE=" + tol + "!LOCATION=" + loc+
        "!SELECTION"+
        "!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
        "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight;
        updateBufferMap(chaine);
}


function sendNextRequest()
{
	
	if( sendingInProgress==true)
	{
	
		if(pile.length > 0)
		{
			
			var header ="";
			
			if(pile.length > 1)
				header="!NBLEFT="+(pile.length-1)+"!";
			//alert(pile[0]);
			
			sendSvgEditionRequest(header+pile[0]);
			
			pile.splice(0,1);
			
		
			return true;
		}
		sendingInProgress= false;

		//FitImage(false);
		reloadAllAfterEdition();
		return false;
	}
	
	return false;
}

function reloadAllAfterEdition()
{
	/*if(mapZoom==true)
	{
		var loc = location.href;
		
		var chaine = szHttpServeur +
			"&ACTION=BuildMap!EMPRISE=" + lastLeftSend  + "@" + lastBottomSend + "@" + 
										  lastWidthSend	  + "@" +  lastHeightSend + 
							"!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
							"!LOCATION=" + loc ;
		updateBufferMap(chaine);
		
		//ActivateFonction(6,currentEditedLayer);
		ActivateFonction(6,currentEditedLayer,"","","",false);

	
	}
	else
	{
		FitImage(false);
	}*/
	RedrawMap();
	ActivateFonction(6,currentEditedLayer,"","","",false);
						
	
			
}
function edtionOk()
{
	sendingInProgress=false;
	
}

function sendSvgEditionRequest(req)
{
	var loc = location.href;
	var newwidth = (mapright - mapleft);
	var tol= 5*newwidth/mapClientwidth;
	
	var chaine = szHttpServeur + "&ACTION=EditionTool!LAYER="+currentEditedLayer + req + "!TOLERANCE=" + tol + "!LOCATION=" + loc+
	"!SELECTION"+
	"!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
	"!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight;

	updateBufferResultatClick(chaine);
}

function sendClear()
{
        var loc = location.href;
	var chaine = szHttpServeur  +
                "&ACTION=clearSvgSelection" + 
		"!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
		"!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
		"!LOCATION=" + loc ;	
	updateBufferMap(chaine);

}

function sendReDraw()
{
        var loc = location.href;
        var chaine = szHttpServeur + "&ACTION=SelectTool!REDRAW"  + "!LOCATION=" + loc+
        "!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
        "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight;
  
        updateBufferMap(chaine);
}

function emptyDivMap()
{
	document.getElementById("divMap").innerHTML ="";
}
