templates/themes/theme/common/map.html.twig line 1

Open in your IDE?
  1. <div id="map"></div>
  2. {# Do not use this API key for production sites - Generate a new key and allow the LIVE and DEV domains #}
  3. {# Get a new API key here: https://developers.google.com/maps/documentation/javascript/get-api-key #}
  4. <script async
  5.     src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAJKHmMyUkGyvinWnKpHqlF6OF-e0KYHTo&loading=async&callback=initMap">
  6. </script>
  7. <script type="text/javascript">
  8.     var map;
  9.     function initMap() {
  10.         var mapOptions = {
  11.             center: new google.maps.LatLng({{ renderSetting(4, 'content') }},{{ renderSetting(5, 'content') }}),
  12.             zoom: 12,
  13.             zoomControl: true,
  14.             mapTypeId: 'roadmap',
  15.             zoomControlOptions: {
  16.                 style: google.maps.ZoomControlStyle.DEFAULT,
  17.             },
  18.             disableDoubleClickZoom: true,
  19.             mapTypeControl: false,
  20.             scaleControl: true,
  21.             scrollwheel: false,
  22.             panControl: true,
  23.             streetViewControl: true,
  24.             draggable: true,
  25.             overviewMapControl: true,
  26.             overviewMapControlOptions: {
  27.                 opened: false,
  28.             },
  29.             styles: [
  30.                 {
  31.                     "featureType": "administrative",
  32.                     "elementType": "labels.text.fill",
  33.                     "stylers": [
  34.                         {
  35.                             "color": "#444444"
  36.                         }
  37.                     ]
  38.                 },
  39.                 {
  40.                     "featureType": "landscape",
  41.                     "elementType": "all",
  42.                     "stylers": [
  43.                         {
  44.                             "color": "#f2f2f2"
  45.                         }
  46.                     ]
  47.                 },
  48.                 {
  49.                     "featureType": "poi",
  50.                     "elementType": "all",
  51.                     "stylers": [
  52.                         {
  53.                             "visibility": "off"
  54.                         }
  55.                     ]
  56.                 },
  57.                 {
  58.                     "featureType": "road",
  59.                     "elementType": "all",
  60.                     "stylers": [
  61.                         {
  62.                             "saturation": -100
  63.                         },
  64.                         {
  65.                             "lightness": 45
  66.                         }
  67.                     ]
  68.                 },
  69.                 {
  70.                     "featureType": "road.highway",
  71.                     "elementType": "all",
  72.                     "stylers": [
  73.                         {
  74.                             "visibility": "simplified"
  75.                         }
  76.                     ]
  77.                 },
  78.                 {
  79.                     "featureType": "road.arterial",
  80.                     "elementType": "labels.icon",
  81.                     "stylers": [
  82.                         {
  83.                             "visibility": "off"
  84.                         }
  85.                     ]
  86.                 },
  87.                 {
  88.                     "featureType": "transit",
  89.                     "elementType": "all",
  90.                     "stylers": [
  91.                         {
  92.                             "visibility": "off"
  93.                         }
  94.                     ]
  95.                 },
  96.                 {
  97.                     "featureType": "water",
  98.                     "elementType": "all",
  99.                     "stylers": [
  100.                         {
  101.                             "color": "#ec3f92"
  102.                         },
  103.                         {
  104.                             "visibility": "on"
  105.                         }
  106.                     ]
  107.                 }
  108.             ]
  109.         }
  110.         var mapElement = document.getElementById('map');
  111.         var map = new google.maps.Map(mapElement, mapOptions);
  112.         var locations = [
  113.             [
  114.                 '{{ sitename }}',
  115.                 `{{ renderSetting(1, 'content') }}`,
  116.                 '{{ renderSetting(2, 'content') }} or {{ renderSetting(15, 'content') }}',
  117.                 '{{ renderSetting(3, 'content') }}',
  118.                 '{{ renderSetting(4, 'content') }}','{{ renderSetting(5, 'content') }}'
  119.             ]
  120.         ];
  121.         for (i = 0; i < locations.length; i++) {
  122.             if (locations[i][0] == 'undefined') { description = ''; } else {name = locations[i][0]; }
  123.             if (locations[i][1] == 'undefined') { description = ''; } else {description = locations[i][1]; }
  124.             if (locations[i][2] == 'undefined') { telephone = ''; } else { telephone = locations[i][2]; }
  125.             if (locations[i][3] == 'undefined') { email = ''; } else { email = locations[i][3]; }
  126.             var infoWindowContent = '<div id="maps-infowindow" class="leading-normal text-sm">'+
  127.             '<div class="mb-3"><strong>'+name+'</strong>'+'<br/>'+description+'</div>'+
  128.             '<div>'+telephone+'<br/>'+email+'</div>'+
  129.             '</div>';
  130.             var infowindow = new google.maps.InfoWindow({content: infoWindowContent});
  131.             var markericon = {
  132.                 url: "",
  133.                 scaledSize: new google.maps.Size(80, 80)
  134.             };
  135.             marker = new google.maps.Marker({
  136.                 icon: markericon,
  137.                 position: new google.maps.LatLng(locations[i][4], locations[i][5]),
  138.                 map: map,
  139.                 title: locations[i][0],
  140.                 desc: description,
  141.                 tel: telephone,
  142.                 email: email
  143.             });
  144.             marker.addListener('click', function() { infowindow.open(map, marker); });
  145.         }
  146.     }
  147. </script>