templates/front/theme1/bloc/map-contact.html.twig line 1

Open in your IDE?
  1. {% set parametre = ParametreSite() %}
  2. {% if param_contact and param_contact.actifMap == 1 %}
  3.     {% if param_contact.typeMap == 1 and param_contact.iframeMap != "" %}
  4.         <iframe class="iframe-map" src="{{param_contact.iframeMap}}" width="100%" height="450" style="border:0;" allowfullscreen loading="lazy" referrerpolicy="no-referrer-when-downgrade"></iframe>
  5.     {% elseif (param_contact.typeMap == 2) %}
  6.         <section id="map" style="width: 100%; height: 400px;"></section>
  7.         <script type="text/javascript">
  8.           $(function(){
  9.             var map = L.map('map',{scrollWheelZoom:false}).setView([{{param_contact.latitude}}, {{param_contact.longitude}}], {{param_contact.zoomMap}});
  10.             L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
  11.                                         
  12.             {% if contacts %}
  13.                 {% for contact in contacts %}
  14.                     var MarkerAdresse = L.marker([{{contact.latitude}}, {{contact.longitude}}], {draggable:false}).addTo(map).bindPopup("<b>{{contact.nomcontact}}</b><br />{{contact.adresse}} <br /> {{contact.codepostal}} {{contact.ville}} {{contact.pays}}").openPopup();
  15.                 {% endfor %}
  16.             {% endif %}        
  17.         });
  18.      
  19.         </script>
  20.         <Link rel="stylesheet" type="text/css" href="{{asset('templates/front/theme1/assets/plugins/leaflet/leaflet.css')}}" />
  21.         <script src="{{asset('templates/front/theme1/assets/plugins/leaflet/leaflet.js')}}"></script>
  22.     {% elseif (param_contact.typeMap == 3 and param_contact.imageMap != "") %}
  23.         <img class="image-map-contact lazyload" data-srcset="{{asset(param_contact.imageMap)}}" src="{{asset(param_contact.imageMap)}}" alt="Map" />
  24.     {% elseif (param_contact.typeMap == 4) %}    
  25.         <section id="map" style="width: 100%; height: 400px;"></section>
  26.         <script src="https://maps.googleapis.com/maps/api/js?key={{parametre.clemap}}"></script>
  27.         
  28.         <script>
  29.             
  30.             var map = new google.maps.Map(document.getElementById('map'), {
  31.             zoom: {{param_contact.zoomMap}},
  32.             center: new google.maps.LatLng({{param_contact.latitude}}, {{param_contact.longitude}}),
  33.             mapTypeId: google.maps.MapTypeId.ROADMAP
  34.             });
  35.             var infowindow = new google.maps.InfoWindow();
  36.             var marker, i;
  37.             {% for contact in contacts %}
  38.             marker = new google.maps.Marker({
  39.                 position: new google.maps.LatLng({{contact.latitude}}, {{contact.longitude}}),
  40.                 map: map
  41.             });
  42.             google.maps.event.addListener(marker, 'click', (function(marker, i) {
  43.                 return function() {
  44.                 infowindow.setContent("<b>{{contact.nomcontact}}</b><br />{{contact.adresse}} <br /> {{contact.codepostal}} {{contact.ville}} {{contact.pays}}");
  45.                 infowindow.open(map, marker);
  46.                 }
  47.             })(marker, i));
  48.             
  49.             {% endfor %}
  50.             
  51.             </script>
  52.         {# <script type="text/javascript">
  53.                 
  54.                 tarteaucitron.services.googlemapsA = {
  55.                 "key": "googlemapsA",
  56.                 "type": "api",
  57.                 "name": "Google Maps",
  58.                 "uri": "http://www.google.com/ads/preferences/",
  59.                 "needConsent": true,
  60.                 "cookies": [],
  61.                 "js": function () {
  62.                     "use strict";
  63.                     var mapOptions,
  64.                         map,
  65.                         uniqIds = [],
  66.                         i;
  67.                 tarteaucitron.addScript('//maps.googleapis.com/maps/api/js?key=&callback=startthis');
  68.                 window.startthis = function () {
  69.                     var locations = [
  70.                     {% for contact in contacts %}
  71.                         ['<b>{{contact.nomcontact}}</b><br />{{contact.adresse}} <br /> {{contact.codepostal}} {{contact.ville}} {{contact.pays}}', {{contact.latitude}},  {{contact.longitude}}],  
  72.                     {% endfor %}
  73.                     ];
  74.                                 
  75.                     var map = new google.maps.Map(document.getElementById('map'), {
  76.                         zoom: <?php echo $zoom_map;?>,
  77.                         center: new google.maps.LatLng({{param_contact.latitude}}, {{param_contact.longitude}}),
  78.                         mapTypeId: google.maps.MapTypeId.ROADMAP
  79.                     });
  80.                 
  81.                     var infowindow = new google.maps.InfoWindow();
  82.                 
  83.                     var marker, i;
  84.                 
  85.                     for (i = 0; i < locations.length; i++) {  
  86.                         marker = new google.maps.Marker({
  87.                         position: new google.maps.LatLng(locations[i][1], locations[i][2]),
  88.                         map: map
  89.                         });
  90.                 
  91.                         google.maps.event.addListener(marker, 'click', (function(marker, i) {
  92.                         return function() {
  93.                             infowindow.setContent(locations[i][0]);
  94.                             infowindow.open(map, marker);
  95.                         }
  96.                         })(marker, i));
  97.                     }
  98.                                             
  99.                 };
  100.           },
  101.             "fallback": function () {
  102.                 "use strict";
  103.                 var id = 'googlemapsA';
  104.                 tarteaucitron.fallback(['googlemaps-canvasA'], tarteaucitron.engage(id));
  105.             } 
  106.             
  107.         };
  108.         </script>  #}
  109.         {# <script>tarteaucitron.user.mapscallback =  "startthis" ;tarteaucitron.user.googlemapsLibraries = "LIBRARIES";</script> #}
  110.     {% endif %}
  111. {% endif %}