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

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