{% extends 'baseTemplate_2.html.twig' %}
{% import 'macro.html.twig' as traiteinfo %}
{% import 'macroEntete.html.twig' as traiteinfoEntete %}
{% import 'macroCarteProducteur.html.twig' as traiteCarte %}
{% import 'macroAbout.html.twig' as traiteinfoAbout %}
{% import 'macroShop.html.twig' as traiteinfoShop %}
{% import 'presentation/macroHead.html.twig' as traiteinfoHead %}
{#{% import 'macro.html.twig' as traiteinfo %}#}
{% block body %}
{% set inc = 0 %}
<body class="home-style2">
<div class="full-width-header header-style1 home1-modifiy">
<!--Header Start-->
{{ traiteinfoHead.infoHead(typeSite,objetAbonne,listeMenu) }}
<!--Header End-->
</div>
<!--Full width header End-->
<div class="main-content">
<div class="rs-breadcrumbs breadcrumbs-overlay">
<div class="breadcrumbs-img">
<br/><br/>
</div>
</div>
{{ traiteCarte.getMap() }}
</div>
{% endblock %}
{% block javascripts %}
{{parent()}}
<script >
$(document).ready(function () {
getNearestCarListFunction() ;
})
function getNearestCarListFunction() {
var map;
var bound;
var markers = [];
var marker;
var myLatLng;
var currentLatLng;
var driverListAjax;
var ajaxInProgress = false;
var mapInitailizeCount = 0;
currentLat = "8.946527";//jQuery("#currentLat").val();
currentLng = "-1.0231939999999895";//jQuery("#currentLng").val();
var currentLatLng = new google.maps.LatLng(currentLat, currentLng);
mapOptions = {
zoom: 8 ,
center: currentLatLng,
mapTypeId: google.maps.MapTypeId.SATELITE,
mapId: 'be545bf72cc6e081'
};
map = new google.maps.Map(document.getElementById("mapCanvas"), mapOptions);
basePath = "https://test.coo.tg/public";
if (ajaxInProgress === true) {
return;
}
ajaxInProgress = true;
jQuery.ajax({
url: "{{ path('api_liste_map_intentions_producteurs',{'typeLocalisation':1, 'idUtil':6940}) }}",
type: 'POST',
cache: false,
dataType: 'json',
timeout: 50000,
data: {},
error: function() {
ajaxInProgress = false;
if (mapInitailizeCount == 0) {
mapInitailizeCount = 1;
}
},
success: function(responseData) {
// console.log("before if In map initailize mapInitailizeCount : " + mapInitailizeCount);
if (mapInitailizeCount == 0) {
bound = new google.maps.LatLngBounds();
mapInitailizeCount = 1;
// console.log("in if In map initailize mapInitailizeCount : " + mapInitailizeCount);
}
//alert(mapInitailizeCount);
var nearestCarArr = [];
var listeLocalisation = responseData.data;
//alert(listeLocalisation[]);
for (var i = 1; i < 3; i++) {
// var donnee = listeLocalisation[i]["type"];
for (var j = 0; j < responseData.data[i]['donnee'].length; j++) {
//alert(listeLocalisation[i]["type"]);
var userLat = responseData.data[i]['donnee'][j].latitude;
var userLng = responseData.data[i]['donnee'][j].longitude;
if (userLat === null || userLng === null) {
continue;
}
if (((userLat - 0.0) < 0.000001) && ((userLng - 0.0) < 0.000001)) {
continue;
}
nearestCarArr.push(responseData.data[i]['donnee'][j]);
}
}
if (nearestCarArr.length > 0) {
for (var j = 0; j < nearestCarArr.length; j++) {
currentLat = nearestCarArr[j].latitude;
currentLng = nearestCarArr[j].longitude;
if (currentLat !== null && currentLng !== null) {
break;
}
}
var urlIcon = "";
for (var k = 0; k < nearestCarArr.length; k++) {
currentLat = nearestCarArr[k].latitude;
currentLng = nearestCarArr[k].longitude;
// tourId = nearestCarArr[k].tourId;
myLatlng = new google.maps.LatLng(currentLat, currentLng);
var iconImage = "";
if ( nearestCarArr[k].typeLocalisation == "1" ) { //tourId === "-1" &&
iconImage = basePath + "/assets/map/farmer.png";
} else if (nearestCarArr[k].typeLocalisation == "3") {
//alert(1);
iconImage = basePath + "/assets/map/fournisseur.png";
}
if ( nearestCarArr[k].typeLocalisation == "1" ) { //tourId === "-1" &&
urlIcon = "{{ path('app_admin_article_producteur',{'idProd':"+ nearestCarArr[k].id+" })}}";
//urlIcon = urlIcon+"/"+nearestCarArr[k].id;
}
contentString = "";
contentString = "<div id='content' style='width:300px;height:100px;'>" ;
/* "<div id='leftMenu' style='height:120px;width:88px;float:left;'>" +
"<img src=" + basePath + nearestCarArr[k].photoUrl + " style='height:78px;width:88px;padding-top:25px;border-radius:60px;'>" +
"</div>" +*/
var prenom = nearestCarArr[k].prenoms;
if(nearestCarArr[k].prenoms == null)
var prenom ="";
if ( nearestCarArr[k].typeLocalisation == "1" ) {
contentString += "<div id='rightMenu' style='height:120px;width:200px;margin-left: 18px;color:#000;'>" +
"<h1 id='firstHeading' class='firstHeading' style='font-size:18px;color:#000;'>" +" "
+ nearestCarArr[k].nomProd+" "+ prenom ; //Nom et prenom
} else if (nearestCarArr[k].typeLocalisation == "3") {
contentString += "<div id='rightMenu' style='height:120px;width:200px;margin-left: 18px;color:#000;'>" +
"<h1 id='firstHeading' class='firstHeading' style='font-size:18px;color:#000;'>" +" "
+ nearestCarArr[k].nomProd ; //Nom et prenom
}
if ( nearestCarArr[k].typeLocalisation == "1" ) {
contentString += "</h1>" +
"<div id='bodyContent' style='color:#000;'>" +
/* "<div>" +
"<p style='font-size:14px;margin-left: 38px;margin-top: 2px;'>" + nearestCarArr[k].nom +" "+ nearestCarArr[k].prenoms + "</p></br>" +
"</div>" +*/
"<div>" +
"<p style='font-size:14px;margin-top: 2px;'> Parcelle : " + nearestCarArr[k].codeSurface + " <br/> Surperficie : "+ nearestCarArr[k].valSurface +"</p>" +
"" +
"<div>"; //Nom et prenom
} else if (nearestCarArr[k].typeLocalisation == "3") {
contentString += "</h1>" +
"<div id='bodyContent'>" +
/* "<div>" +
"<p style='font-size:14px;margin-left: 38px;margin-top: 2px;'>" + nearestCarArr[k].nom +" "+ nearestCarArr[k].prenoms + "</p></br>" +
"</div>" +*/
"<div>" +
"("+currentLat+", "+currentLng+") </div>" +
"<div>";
}
contentString += "</div>" +
"</div>" +
"</div>" +
"</div>";
marker = new google.maps.Marker({
map: map,
icon: new google.maps.MarkerImage(iconImage),
position: myLatlng,
url: urlIcon,
info: contentString
});
markers.push(marker);
bound.extend(myLatlng);
if (mapInitailizeCount == 1) {
map.fitBounds(bound);
mapInitailizeCount = 2;
}
var infowindow;
google.maps.event.addListener(marker, 'mouseover', function() {
infowindow = new google.maps.InfoWindow({});
infowindow.setContent(this.info);
infowindow.open(map, this);
});
google.maps.event.addListener(marker, 'mouseout', function() {
infowindow.close(map, this);
});
google.maps.event.addListener(marker, 'click', function() {
window.location.href = this.url;
});
}
}
ajaxInProgress = false;
}
});
}
</script>
{% endblock %}