 //<![CDATA[
 /* Chargement du module "maps" dans sa version "2.x" */
 google.load("maps", "2.x",{"other_params":"sensor=false"});
 var maCarte;
 var fichierXML;
// var url = "http://maps.google.fr/maps/ms?ie=UTF8&hl=fr&oe=UTF8&msa=0&msid=117831908886307560862.00047aea0bab92e77ab90&output=kml"; 
var url = "http://maps.google.fr/maps/ms?ie=UTF8&hl=fr&vps=2&jsv=199b&oe=UTF8&msa=0&msid=117831908886307560862.00047d81bed787ffd0723&output=kml";
 /* Fonction initialize() */
 function initialize() {
 /* Si le navigateur est compatible avec l'API de Google Maps ... */
 if (google.maps.BrowserIsCompatible()) {
 /* ... fichierXML : Fichier au format XML que l'on charge pour l'afficher sur la carte ... */
   // var url= "http://maps.google.fr/maps/ms?ie=UTF8&hl=fr&vps=1&jsv=154c&oe=UTF8&msa=0&msid=115115239782170342035.00045c5d8b68ccf0d0247&output=kml";
 fichierXML = new google.maps.GeoXml(url);
 /* ... Création d'une nouvelle carte nommée "maCarte" qui s'affichera à l'intérieur de la balise <div> ayant pour identifiant id="EmplacementDeMaCarte" ... */
 maCarte = new google.maps.Map2(document.getElementById("EmplacementDeMaCarte"));
 /* ... La carte nommée "maCarte" est centrée sur la Latitude 33.590443, la Longitude-7.592089, avec un niveau de zoom égal à 13 ... */
 maCarte.setCenter(new google.maps.LatLng(33.590443,-7.592089), 13);
 /* ... Affiche les boutons et contrôles identiques à ceux que l'on trouve sur http://maps.google.fr ... */
 maCarte.setUIToDefault();
//*********************
 /* ... On ajoute les données du fichier 'fichierKML' sur la carte nommée 'maCarte' ... */
 if ( texte = file2('../trace.php?rnd='+ rnd() ) )
	{
          eval( texte );
 }
        GEvent.addListener( maCarte, "move", function() {
        checkBounds();
        });
	    var allowedBounds = new GLatLngBounds( new GLatLng(33.255909,-8.50783), new GLatLng(33.706379,-7.389274) );
        // If the map position is out of range, move it back
        function checkBounds() {
        // Perform the check and return if OK
        if ( allowedBounds.contains(maCarte.getCenter())) {
          return;
        }
        // It`s not OK, so find the nearest allowed point and move there
        var C = maCarte.getCenter();
        var X = C.lng();
        var Y = C.lat();
 
        var AmaxX = allowedBounds.getNorthEast().lng();
        var AmaxY = allowedBounds.getNorthEast().lat();
        var AminX = allowedBounds.getSouthWest().lng();
        var AminY = allowedBounds.getSouthWest().lat();
 
        if (X < AminX) {X = AminX;}
        if (X > AmaxX) {X = AmaxX;}
        if (Y < AminY) {Y = AminY;}
        if (Y > AmaxY) {Y = AmaxY;}
        //alert ("Restricting "+Y+" "+X);
        maCarte.setCenter(new GLatLng(Y,X));
      }
	  // 
      var mt = maCarte.getMapTypes();
      // Overwrite the getMinimumResolution() and getMaximumResolution() methods
      for (var i=0; i<mt.length; i++) {
        mt[i].getMinimumResolution = function() {return 12;}
       // mt[i].getMaximumResolution = function() {return 18;}
      }
	  maCarte.addOverlay( fichierXML );
 /* Si le navigateur n'est pas compatible avec l'API de Google Maps ... */
 }else{
 /* ... affichage du message "Désolé, mais votre navigateur n'est pas compatible avec Google Maps". */
 alert('Désolé, mais votre navigateur n\'est pas compatible avec Google Maps');
 }
 }
 
function changePostion(){
	
	if ( changePostion.arguments.length >  0 )
	{
		 para1      = changePostion.arguments[0];
         para2      = changePostion.arguments[1];
         idStation  = changePostion.arguments[2];
	} 
	 else 
	{ 
      var station = document.getElementById("station").value;
	  if ( station == "" ) return ;
      str       = station.split(',');
      para1     = str[0];
      para2     = str[1];
      idStation = str[2];
    }
	
   var point = new google.maps.LatLng(para1,para2);
  /* Si le navigateur est compatible avec l'API de Google Maps ... */
	if (google.maps.BrowserIsCompatible()) {
  /* ... fichierXML : Fichier au format XML que l'on charge pour l'afficher sur la carte ... */
  // var url= "http://maps.google.fr/maps/ms?ie=UTF8&hl=fr&vps=1&jsv=154c&oe=UTF8&msa=0&msid=115115239782170342035.00045c5d8b68ccf0d0247&output=kml";
	 fichierXML = new google.maps.GeoXml(url);
  /* ... Création d'une nouvelle carte nommée "maCarte" qui s'affichera à l'intérieur de la balise <div> ayant pour identifiant id="EmplacementDeMaCarte" ... */
     maCarte    = new google.maps.Map2(document.getElementById("EmplacementDeMaCarte"));
  /* ... La carte nommée "maCarte" est centrée sur la Latitude 48.159444, la Longitude 0.099907, avec un niveau de zoom égal à 12 ... */
     maCarte.setCenter(new google.maps.LatLng(para1,para2), 16);
  /* ... Affiche les boutons et contrôles identiques à ceux que l'on trouve sur http://maps.google.fr ... */
     maCarte.setUIToDefault();
  // Definir la surface a voir 
     GEvent.addListener( maCarte, "move", function() {
     checkBounds();
     });
	 
	 var allowedBounds = new GLatLngBounds( new GLatLng(33.255909,-8.50783), new GLatLng(33.706379,-7.389274) );
        // If the map position is out of range, move it back
     function checkBounds() 
	 {
			// Perform the check and return if OK
			if ( allowedBounds.contains(maCarte.getCenter())) {
			     return;
			}
			// It`s not OK, so find the nearest allowed point and move there
			var C = maCarte.getCenter();
			var X = C.lng();
			var Y = C.lat();
	 
			var AmaxX = allowedBounds.getNorthEast().lng();
			var AmaxY = allowedBounds.getNorthEast().lat();
			var AminX = allowedBounds.getSouthWest().lng();
			var AminY = allowedBounds.getSouthWest().lat();
	 
			if (X < AminX) {X = AminX;}
			if (X > AmaxX) {X = AmaxX;}
			if (Y < AminY) {Y = AminY;}
			if (Y > AmaxY) {Y = AmaxY;}
			//alert ("Restricting "+Y+" "+X);
			maCarte.setCenter(new GLatLng(Y,X));
      }
	  // 
      var mt = maCarte.getMapTypes();
      // Overwrite the getMinimumResolution() and getMaximumResolution() methods
      for (var i=0; i<mt.length; i++) {
         mt[i].getMinimumResolution = function() {return 12;}
        // mt[i].getMaximumResolution = function() {return 18;}
      }
      // fin de la surface à voir
  
	 if ( texte = file2('../station.php?idStation='+idStation+'&rnd='+ rnd() ) ) {
	 ///-------------------------------
          maCarte.openInfoWindowHtml( point , texte );
	 }
     maCarte.addOverlay( fichierXML );
	 if ( newTrace = file2('../trace.php?idStation='+idStation+'&rnd='+ rnd() ) )
	 {
	     eval( newTrace );
	 }
    } else {
      /* ... affichage du message "Désolé, mais votre navigateur n'est pas compatible avec Google Maps". */
      alert('Désolé, mais votre navigateur n\'est pas compatible avec Google Maps');
    }

}
 
 /* Appelle la fonction "initialize" lorsque la page web sera chargée */
 google.setOnLoadCallback(initialize);
 //]]>
 

