templates/areas/googlemaps/view.html.twig line 1

Open in your IDE?
  1. {% set azz = '' %}
  2. {% if pimcore_select("bullets").getData() != '' %}
  3.     {% set azz = pimcore_select("bullets").getData() %}
  4.     {% set azzColor = pimcore_select("bulletColor").getData() %}
  5.     {% if azzColor is empty %}
  6.         {% set azzColor = 'stwh-rot-2024' %}
  7.     {% endif %}
  8. {% endif %}
  9. {% if editmode %}
  10.     <div class="bg-gray-100 p-5 wysiwyg-heading">
  11.         {% include 'areaHeadAndFooter.html.twig' with { 'header': 'STWH: Googlemaps' } %}
  12.         {% include 'padding.html.twig' %}
  13.         <div class="my-3 flex flex-wrap overflow-hidden">
  14.             <div class="w-1/4 overflow-hidden">
  15.                 Darstellungsbreite der Karte:
  16.             </div>
  17.             <div class="w-1/4 overflow-hidden pr-3">
  18.                 {{ pimcore_select("anzeigebreite", {
  19.                     "store": [
  20.                         ["c", "Content-Breite"],
  21.                         ["f", "Volle Bildschirmbreite"]
  22.                     ],
  23.                     "defaultValue" : "f",
  24.                     "width" : 200
  25.                 }) }}
  26.             </div>
  27.             <div class="w-1/4 overflow-hidden pl-3">
  28.                 Icon für die Marker:
  29.             </div>
  30.             <div class="w-1/4 overflow-hidden">
  31.                 {{ pimcore_image("mapicon", {
  32.                     "height" : 100
  33.                 }) }}
  34.             </div>
  35.         </div>
  36.         <hr />
  37.         <div class="my-3 flex flex-wrap overflow-hidden">
  38.             <div class="w-1/4 overflow-hidden">
  39.                 Höhe der Karte<br />(default ist 300px):
  40.             </div>
  41.             <div class="w-1/4 overflow-hidden">
  42.                 {{ pimcore_numeric("mapHeight", {
  43.                     "minValue": 1
  44.                 }) }}
  45.             </div>
  46.             <div class="w-1/4 overflow-hidden">
  47.                 Zoomfaktor<br />(0 bis 18):
  48.             </div>
  49.             <div class="w-1/4 overflow-hidden">
  50.                 {{ pimcore_numeric("mapZoom", {
  51.                     "minValue": 0,
  52.                     "maxValue": 18
  53.                 }) }}
  54.             </div>
  55.         </div>
  56.         <hr />
  57.         <div class="my-3 flex flex-wrap overflow-hidden">
  58.             <div class="w-1/4 overflow-hidden">
  59.                 Content-Überschrift: (optional)
  60.             </div>
  61.             <div class="w-3/4 overflow-hidden">
  62.                 {{ pimcore_input("mapHeadline", { "height" : 50 }) }}
  63.             </div>
  64.         </div>
  65.         <div class="my-3 flex flex-wrap overflow-hidden">
  66.             <div class="w-1/4 overflow-hidden">
  67.                 SEO:
  68.             </div>
  69.             <div class="w-1/4 overflow-hidden">
  70.                 {% include 'seo.html.twig' with { 'name': 'seo', 'default' : 'h2' } %}
  71.             </div>
  72.             <div class="w-1/2 overflow-hidden">
  73.                 {% include 'color-selector.html.twig' with { 'name': 'seoHeadlineColor', 'description': 'Farbe der Überschrift', 'type': 'accordeon' } %}
  74.             </div>
  75.         </div>
  76.         <hr />
  77.         <div class="my-3 flex flex-wrap overflow-hidden">
  78.             <div class="w-1/4 overflow-hidden">
  79.                 Teaser: (optional)
  80.             </div>
  81.             <div class="w-1/4 overflow-hidden {{ azz }} list-{{ azzColor }}">
  82.                 {{ pimcore_wysiwyg("mapTeaser", { "height" : 100 }) }}
  83.                 {% include 'bullet-points.html.twig' with { 'name': 'bullets', 'description': 'Aufzählungszeichen' } %}
  84.             </div>
  85.             <div class="w-1/4 overflow-hidden">
  86.                 {% include 'color-selector.html.twig' with { 'name': 'bulletColor', 'description': 'Farbe der Bullets', 'default': 'stwh-rot-2024' } %}
  87.             </div>
  88.             <div class="w-1/4 overflow-hidden">
  89.                 Dummy-Bild (DSGVO-Abfrage):
  90.             </div>
  91.             <div class="w-1/4 overflow-hidden">
  92.                 {{ pimcore_image("dsgvoDummy") }}
  93.             </div>
  94.         </div>
  95.         <hr />
  96.         <div class="my-3 flex flex-wrap overflow-hidden">
  97.             <div class="w-1/4 overflow-hidden">
  98.                 Google-Map Adressen
  99.             </div>
  100.             <div class="w-3/4 overflow-hidden">
  101.                 {{ pimcore_relations("google", {
  102.                     "types": ["object"]
  103.                 }) }}
  104.             </div>
  105.         </div>
  106.     </div>
  107.     {% include 'areaHeadAndFooter.html.twig' with { 'footer': true } %}
  108. {% else %}
  109.     {% set mapicon = pimcore_image("mapicon").getSrc() %}
  110.     {% set mapId = random() %}
  111.     {% set height = 300 %}
  112.     {% if pimcore_numeric("mapHeight").getData() > 0 %}
  113.         {% set height = pimcore_numeric("mapHeight").getData() %}
  114.     {% endif %}
  115.     {% set zoom = 10 %}
  116.     {% if pimcore_numeric("mapZoom").getData() > 0 %}
  117.         {% set zoom = pimcore_numeric("mapZoom").getData() %}
  118.     {% endif %}
  119.     {% set containerBreite = 'mx-0' %}
  120.     {% if pimcore_select("anzeigebreite").getData() == 'c' %}
  121.         {% set containerBreite = 'container mx-auto px-5' %}
  122.     {% endif %}
  123.     <section class="wysiwyg-heading {{ pimcore_select('paddingTop') }} {{ pimcore_select('paddingBottom') }} relative bg-{{ pimcore_select('color') }}">
  124.         <div class="container mx-auto px-5 pb-5">
  125.             <div class="flex flex-wrap">
  126.                 {% if pimcore_input("mapHeadline") != '' %}
  127.                     {% set seo = pimcore_select("seo").getData() %}
  128.                     <{{ seo }} class="text-{{ pimcore_select("seoHeadlineColor").getData() }} block mb-5 md:mb-10 text-2xl md:text-4xl lg:text-5xl font-bold">
  129.                         {{ pimcore_input("mapHeadline") }}
  130.                     </{{ seo }}>
  131.                 {% endif %}
  132.                 {% if pimcore_wysiwyg("mapTeaser") != '' %}
  133.                     <div class="w-full lg:mx-auto">
  134.                         <div class="text-lg {{ azz }} list-{{ azzColor }}">
  135.                             {{ pimcore_wysiwyg("mapTeaser") }}
  136.                         </div>
  137.                     </div>
  138.                 {% endif %}
  139.             </div>
  140.         </div>
  141.         <div class="{{ containerBreite }}">
  142.             <div class="map" id="map-{{ mapId }}" style="height:{{ height }}px;">
  143.                 <div class="w-full h-full bg-cover bg-center" id="map-placeholder" style="background: url('{{ pimcore_image("dsgvoDummy").getSrc() }}');">
  144.                     <div class="w-full h-full flex flex-col justify-center items-center backdrop-blur-sm">
  145.                         <div class="bg-white w-full lg:w-1/4 text-center p-5">
  146.                             <p class="font-bold">Google Maps wurde geblockt,<br />
  147.                             da Sie nicht Ihr Einverständnis zu dem<br />
  148.                             erforderlichen Cookie gegeben haben.</p>
  149.                             <button
  150.                                 onclick="showOnce();"
  151.                                 class="
  152.                                 mt-3
  153.                                 px-5
  154.                                 py-2
  155.                                 w-full
  156.                                 block
  157.                                 hover:bg-red-600
  158.                                 hover:text-white
  159.                                 text-red-600
  160.                                 relative
  161.                                 focus:outline-none
  162.                                 border-2
  163.                                 border-solid
  164.                                 rounded-lg
  165.                                 border-red-600
  166.                                 text-sm
  167.                                 text-center
  168.                                 tracking-widest"
  169.                                 type="button">
  170.                                 Diese Karte einmalig laden
  171.                             </button>
  172.                             <button
  173.                                 onclick="showEver();"
  174.                                 class="
  175.                                 mt-3
  176.                                 px-5
  177.                                 py-2
  178.                                 w-full
  179.                                 block
  180.                                 hover:bg-red-600
  181.                                 hover:text-white
  182.                                 text-red-600
  183.                                 relative
  184.                                 focus:outline-none
  185.                                 border-2
  186.                                 border-solid
  187.                                 rounded-lg
  188.                                 border-red-600
  189.                                 text-sm
  190.                                 text-center
  191.                                 tracking-widest"
  192.                                 type="button">
  193.                                 Karten immer laden
  194.                             </button>
  195.                         </div>
  196.                     </div>
  197.                 </div>
  198.             </div>
  199.         </div>
  200.     </section>
  201.     <script type="text/javascript">
  202.     window.googleMapsApiKey = "{{ document.getProperty('googleAPI') }}";
  203.     function showOnce() {
  204.         window.activateGoogleMaps();
  205.     }
  206.     function showEver() {
  207.         window.activateGoogleMaps(true);
  208.     }
  209.     function googleMapsInit() {
  210.         // Herne 51.5402529, 7.2050891
  211.         var myLatLng = {
  212.             lat            :    51.5402529,
  213.             lng            :    7.2050891
  214.         };
  215.         var locations = new Array();
  216.         {# @array adressen wird im Brick-Controller definiert #}
  217.         {% if adressen is defined %}
  218.             {% for data in adressen %}
  219.                 {% set addr = data.address %}
  220.                 {% set addr = addr|replace({"\n": "-", "\r": "-", "\t": "-"}) %}
  221.                 locations.push({
  222.                     address : '{{ addr }}',
  223.                     lat : '{{ data.lat }}',
  224.                     lng : '{{ data.lng }}',
  225.                     label : '{{ data.label }}',
  226.                     marker : '{{ mapicon }}'
  227.                 });
  228.             {% endfor %}
  229.         {% endif %}
  230.         var mapOptions = {
  231.             zoom: {{ zoom }},
  232.             center: myLatLng,
  233.             styles: [
  234.                 {
  235.                     "featureType": "administrative",
  236.                     "elementType": "labels",
  237.                     "stylers": [
  238.                         {
  239.                             "visibility": "simplified"
  240.                         },
  241.                         {
  242.                             "color": "#ff0000"
  243.                         }
  244.                     ]
  245.                 },
  246.                 {
  247.                     "featureType": "administrative",
  248.                     "elementType": "labels.text.fill",
  249.                     "stylers": [
  250.                         {
  251.                             "color": "#444444"
  252.                         }
  253.                     ]
  254.                 },
  255.                 {
  256.                     "featureType": "administrative.country",
  257.                     "elementType": "labels",
  258.                     "stylers": [
  259.                         {
  260.                             "color": "#fc0505"
  261.                         },
  262.                         {
  263.                             "visibility": "on"
  264.                         }
  265.                     ]
  266.                 },
  267.                 {
  268.                     "featureType": "administrative.province",
  269.                     "elementType": "labels",
  270.                     "stylers": [
  271.                         {
  272.                             "color": "#ff0000"
  273.                         },
  274.                         {
  275.                             "visibility": "simplified"
  276.                         }
  277.                     ]
  278.                 },
  279.                 {
  280.                     "featureType": "administrative.locality",
  281.                     "elementType": "labels",
  282.                     "stylers": [
  283.                         {
  284.                             "color": "#ff0000"
  285.                         },
  286.                         {
  287.                             "visibility": "simplified"
  288.                         }
  289.                     ]
  290.                 },
  291.                 {
  292.                     "featureType": "administrative.neighborhood",
  293.                     "elementType": "labels",
  294.                     "stylers": [
  295.                         {
  296.                             "color": "#ff0000"
  297.                         },
  298.                         {
  299.                             "visibility": "simplified"
  300.                         }
  301.                     ]
  302.                 },
  303.                 {
  304.                     "featureType": "administrative.land_parcel",
  305.                     "elementType": "labels",
  306.                     "stylers": [
  307.                         {
  308.                             "color": "#ff0000"
  309.                         },
  310.                         {
  311.                             "visibility": "simplified"
  312.                         }
  313.                     ]
  314.                 },
  315.                 {
  316.                     "featureType": "landscape",
  317.                     "elementType": "all",
  318.                     "stylers": [
  319.                         {
  320.                             "color": "#f2f2f2"
  321.                         }
  322.                     ]
  323.                 },
  324.                 {
  325.                     "featureType": "poi",
  326.                     "elementType": "all",
  327.                     "stylers": [
  328.                         {
  329.                             "visibility": "off"
  330.                         }
  331.                     ]
  332.                 },
  333.                 {
  334.                     "featureType": "road",
  335.                     "elementType": "all",
  336.                     "stylers": [
  337.                         {
  338.                             "saturation": -100
  339.                         },
  340.                         {
  341.                             "lightness": 45
  342.                         }
  343.                     ]
  344.                 },
  345.                 {
  346.                     "featureType": "road.highway",
  347.                     "elementType": "all",
  348.                     "stylers": [
  349.                         {
  350.                             "visibility": "simplified"
  351.                         }
  352.                     ]
  353.                 },
  354.                 {
  355.                     "featureType": "road.arterial",
  356.                     "elementType": "labels.icon",
  357.                     "stylers": [
  358.                         {
  359.                             "visibility": "off"
  360.                         }
  361.                     ]
  362.                 },
  363.                 {
  364.                     "featureType": "transit",
  365.                     "elementType": "all",
  366.                     "stylers": [
  367.                         {
  368.                             "visibility": "off"
  369.                         }
  370.                     ]
  371.                 },
  372.                 {
  373.                     "featureType": "water",
  374.                     "elementType": "all",
  375.                     "stylers": [
  376.                         {
  377.                             "color": "#ffffff"
  378.                         },
  379.                         {
  380.                             "visibility": "on"
  381.                         }
  382.                     ]
  383.                 }
  384.             ]
  385.         };
  386.         var mapElement = document.getElementById('map-{{ mapId }}');
  387.         var map = new google.maps.Map(mapElement, mapOptions);
  388.         var infowindow        =    new google.maps.InfoWindow();
  389.         for (var i = 0; i < locations.length; i++) {
  390.             marker = new google.maps.Marker({
  391.                 position    :    new google.maps.LatLng(locations[i]['lat'], locations[i]['lng']),
  392.                 map            :    map,
  393.                 animation    :    google.maps.Animation.DROP,
  394.                 icon        :    new google.maps.MarkerImage( locations[i]['marker'], null, null, null, new google.maps.Size(57, 57) ),
  395.             });
  396.             google.maps.event.addListener(marker, 'click', (function(marker, i) {
  397.                 return function() {
  398.                     content = '';
  399.                     route = '';
  400.                     content += '<span class="font-bold text-xl">' + locations[i]['label'] + '</span>';
  401.                     var addr = locations[i]['address'].split('-');
  402.                     addr.forEach(element => {
  403.                         content += '<p class="text-xl">' + element + '</p>';
  404.                         route += element + '+';
  405.                     });
  406.                     var astr = encodeURIComponent(route.replace(' ', '+'));
  407.                     content += '<p><a class="text-xl block text-red-600 pt-1 hover:underline" href="http://maps.google.com/maps?daddr=' + astr + '" target="_blank">Route planen</a></p>';
  408.                     infowindow.setContent( content );
  409.                     infowindow.open(map, marker);
  410.                 }
  411.             })(marker, i));
  412.         }
  413.     }
  414.     </script>
  415. {% endif %}