templates/site/Default/carte.html.twig line 1

Open in your IDE?
  1. {% extends 'baseTemplate_2.html.twig' %}
  2. {% import 'macro.html.twig' as traiteinfo %}
  3. {% import 'macroEntete.html.twig' as traiteinfoEntete %}
  4. {% import 'macroCarteProducteur.html.twig' as traiteCarte %}
  5. {% import 'macroAbout.html.twig' as traiteinfoAbout %}
  6. {% import 'macroShop.html.twig' as traiteinfoShop %}
  7. {% import 'presentation/macroHead.html.twig' as traiteinfoHead %}
  8. {#{% import 'macro.html.twig' as traiteinfo %}#}
  9. {% block body %}
  10. {% set inc = 0 %}
  11. <body class="home-style2">
  12.     <div class="full-width-header header-style1 home1-modifiy">
  13.                 <!--Header Start-->
  14.                {{ traiteinfoHead.infoHead(typeSite,objetAbonne,listeMenu) }}
  15.                 <!--Header End-->
  16.     </div>
  17.             <!--Full width header End-->
  18.      <div class="main-content">
  19.         <div class="rs-breadcrumbs breadcrumbs-overlay">
  20.                 <div class="breadcrumbs-img">
  21.                     <br/><br/>
  22.                 </div>
  23.                 
  24.             </div>
  25.      
  26.      
  27.       {{ traiteCarte.getMap() }}
  28.             
  29.      </div>
  30.            
  31. {% endblock %}
  32. {% block javascripts %}
  33.     {{parent()}}
  34.     
  35.     
  36. <script >
  37.     $(document).ready(function () {
  38.         
  39.         getNearestCarListFunction() ;
  40.         
  41.     })
  42.     
  43.  function getNearestCarListFunction() {
  44.     
  45.     var map;
  46.     var bound;
  47.     var markers = [];
  48.     var marker;
  49.     var myLatLng;
  50.     var currentLatLng;
  51.     var driverListAjax;
  52.     var ajaxInProgress = false;
  53.     var mapInitailizeCount = 0;
  54.      currentLat = "8.946527";//jQuery("#currentLat").val();
  55.     currentLng = "-1.0231939999999895";//jQuery("#currentLng").val();
  56.     var currentLatLng = new google.maps.LatLng(currentLat, currentLng);
  57.     mapOptions = {
  58.         zoom: 8  ,
  59.         center: currentLatLng,
  60.         mapTypeId: google.maps.MapTypeId.SATELITE,
  61.         mapId: 'be545bf72cc6e081'
  62.     };
  63.     map = new google.maps.Map(document.getElementById("mapCanvas"), mapOptions);
  64.     basePath = "https://test.coo.tg/public";
  65.     
  66.     if (ajaxInProgress === true) {
  67.         return;
  68.     }
  69.       
  70.     ajaxInProgress = true;
  71.     jQuery.ajax({
  72.         url: "{{ path('api_liste_map_intentions_producteurs',{'typeLocalisation':1, 'idUtil':6940}) }}",
  73.         type: 'POST',
  74.         cache: false,
  75.         dataType: 'json',
  76.         timeout: 50000,
  77.         data: {},
  78.         error: function() {
  79.             ajaxInProgress = false;
  80.             if (mapInitailizeCount == 0) {
  81.              
  82.                 mapInitailizeCount = 1;
  83.             }
  84.         },
  85.         success: function(responseData) {
  86.             
  87.            // console.log("before if In map initailize mapInitailizeCount : " + mapInitailizeCount);
  88.            
  89.             if (mapInitailizeCount == 0) {
  90.                 
  91.                 bound = new google.maps.LatLngBounds();
  92.                 mapInitailizeCount = 1;
  93.                 
  94.                // console.log("in if In map initailize mapInitailizeCount : " + mapInitailizeCount);
  95.             }
  96.             //alert(mapInitailizeCount);
  97.             var nearestCarArr = [];
  98.             var listeLocalisation = responseData.data;
  99.             //alert(listeLocalisation[]);
  100.             for (var i = 1; i < 3; i++) {
  101.                // var donnee = listeLocalisation[i]["type"];
  102.                 
  103.                 for (var j = 0; j < responseData.data[i]['donnee'].length; j++) {
  104.                     //alert(listeLocalisation[i]["type"]);
  105.                     var userLat = responseData.data[i]['donnee'][j].latitude;
  106.                     var userLng = responseData.data[i]['donnee'][j].longitude;
  107.                     
  108.                    
  109.                     if (userLat === null || userLng === null) {
  110.                         continue;
  111.                     }
  112.                     if (((userLat - 0.0) < 0.000001) && ((userLng - 0.0) < 0.000001)) {
  113.                         continue;
  114.                     }
  115.                     nearestCarArr.push(responseData.data[i]['donnee'][j]);
  116.                 }
  117.             }
  118.             if (nearestCarArr.length > 0) {
  119.                 
  120.                 for (var j = 0; j < nearestCarArr.length; j++) {
  121.                     currentLat = nearestCarArr[j].latitude;
  122.                     currentLng = nearestCarArr[j].longitude;
  123.                     if (currentLat !== null && currentLng !== null) {
  124.                         break;
  125.                     }
  126.                 }
  127.                 var urlIcon = "";
  128.                 for (var k = 0; k < nearestCarArr.length; k++) {
  129.                     currentLat = nearestCarArr[k].latitude;
  130.                     currentLng = nearestCarArr[k].longitude;
  131.                    // tourId = nearestCarArr[k].tourId;
  132.                     myLatlng = new google.maps.LatLng(currentLat, currentLng);
  133.                     var iconImage = "";
  134.                     if ( nearestCarArr[k].typeLocalisation == "1" ) {  //tourId === "-1" &&
  135.                         iconImage = basePath + "/assets/map/farmer.png";
  136.                     } else if (nearestCarArr[k].typeLocalisation  == "3") {
  137.                         //alert(1);
  138.                         iconImage = basePath + "/assets/map/fournisseur.png";
  139.                     }
  140.                     
  141.                     if ( nearestCarArr[k].typeLocalisation == "1" ) {  //tourId === "-1" &&
  142.                         urlIcon = "{{ path('app_admin_article_producteur',{'idProd':"+ nearestCarArr[k].id+" })}}";
  143.                         //urlIcon = urlIcon+"/"+nearestCarArr[k].id;
  144.                     } 
  145.                     
  146.                   
  147.                     contentString = "";
  148.                     contentString = "<div id='content' style='width:300px;height:100px;'>" ;
  149.                        /* "<div id='leftMenu' style='height:120px;width:88px;float:left;'>" +
  150.                         "<img  src=" + basePath + nearestCarArr[k].photoUrl + " style='height:78px;width:88px;padding-top:25px;border-radius:60px;'>" +
  151.                         "</div>" +*/
  152.                     var prenom = nearestCarArr[k].prenoms;
  153.                     if(nearestCarArr[k].prenoms == null)
  154.                         var prenom ="";
  155.                     if ( nearestCarArr[k].typeLocalisation == "1" ) { 
  156.                        contentString +=  "<div id='rightMenu' style='height:120px;width:200px;margin-left: 18px;color:#000;'>" +
  157.                         "<h1 id='firstHeading' class='firstHeading' style='font-size:18px;color:#000;'>" +" "
  158.                          + nearestCarArr[k].nomProd+" "+ prenom ;    //Nom et prenom
  159.                     } else if (nearestCarArr[k].typeLocalisation  == "3") {
  160.                          contentString +=  "<div id='rightMenu' style='height:120px;width:200px;margin-left: 18px;color:#000;'>" +
  161.                         "<h1 id='firstHeading' class='firstHeading' style='font-size:18px;color:#000;'>" +" "
  162.                          + nearestCarArr[k].nomProd ;    //Nom et prenom
  163.                     }
  164.                   
  165.                     if ( nearestCarArr[k].typeLocalisation == "1" ) { 
  166.                        contentString += "</h1>" +
  167.                         "<div id='bodyContent' style='color:#000;'>" +
  168.                        /* "<div>" +
  169.                         "<p style='font-size:14px;margin-left: 38px;margin-top: 2px;'>" + nearestCarArr[k].nom +" "+ nearestCarArr[k].prenoms + "</p></br>" +
  170.                         "</div>" +*/                    
  171.                             "<div>" +
  172.                             "<p style='font-size:14px;margin-top: 2px;'> Parcelle  : " + nearestCarArr[k].codeSurface + " <br/> Surperficie : "+ nearestCarArr[k].valSurface +"</p>" +
  173.                             "" +
  174.                         "<div>";    //Nom et prenom
  175.                     } else if (nearestCarArr[k].typeLocalisation  == "3") {
  176.                          contentString += "</h1>" +
  177.                         "<div id='bodyContent'>" +
  178.                        /* "<div>" +
  179.                         "<p style='font-size:14px;margin-left: 38px;margin-top: 2px;'>" + nearestCarArr[k].nom +" "+ nearestCarArr[k].prenoms + "</p></br>" +
  180.                         "</div>" +*/                    
  181.                             "<div>" +
  182.                             "("+currentLat+", "+currentLng+") </div>" +
  183.                         "<div>";
  184.                     }
  185.                     
  186.                    
  187.                     contentString += "</div>" +
  188.                         "</div>" +
  189.                         "</div>" +
  190.                         "</div>";
  191.                   
  192.                     marker = new google.maps.Marker({
  193.                         map: map,
  194.                         icon: new google.maps.MarkerImage(iconImage),
  195.                         position: myLatlng,
  196.                         url: urlIcon,
  197.                         info: contentString
  198.                     });
  199.                     markers.push(marker);
  200.                     bound.extend(myLatlng);
  201.                     if (mapInitailizeCount == 1) {
  202.                         map.fitBounds(bound);
  203.                         mapInitailizeCount = 2;
  204.                       
  205.                     }
  206.                     
  207.                     
  208.                      var infowindow;
  209.                     google.maps.event.addListener(marker, 'mouseover', function() {
  210.                         infowindow = new google.maps.InfoWindow({});
  211.                         infowindow.setContent(this.info);
  212.                         infowindow.open(map, this);
  213.                     });
  214.                     google.maps.event.addListener(marker, 'mouseout', function() {
  215.                         infowindow.close(map, this);
  216.                     });
  217.                      google.maps.event.addListener(marker, 'click', function() {
  218.                         window.location.href = this.url;
  219.                     });
  220.                    
  221.                 }
  222.             }
  223.            
  224.             ajaxInProgress = false;
  225.         }
  226.     });
  227. }  
  228. </script>
  229. {% endblock %}